From 9d605e2f6fbdd5f4680d81982b0f86b9391b6143 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 10 Dec 2024 10:15:41 +0800 Subject: [PATCH 01/85] 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 29f81d8..c9db8b2 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 37e4cb9..e4013df 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 3462fb7..8bd8055 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 0000000..c337346 --- /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 0000000..eda726e --- /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 0000000..87a4a3e --- /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 0000000..9f48fa5 --- /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 0000000..761fee8 --- /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 0000000..e84d7c1 --- /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 0000000..2783698 --- /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 0000000..d4e3b9a --- /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 0000000..2eed15c --- /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 0000000..9840ee5 --- /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 0000000..a2ceeb3 --- /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 0000000..e69c0cb --- /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 0000000..8c8f589 --- /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 0000000..333af08 --- /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 0000000..370e40c --- /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 0000000..7ea8430 --- /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 0000000..9fad104 --- /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 0000000..39f2c57 --- /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 0000000..c913005 --- /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 0000000..9750544 --- /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 0000000..6b38bb7 --- /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 0000000..17daab5 --- /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 0000000..4be437e --- /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 0000000..5634cb9 --- /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 0000000..fafbed8 --- /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 0000000..c8aee05 --- /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 0000000..8dd9ff3 --- /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 0000000..4956aaa --- /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 0000000..94efe54 --- /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 0000000..0cc50c9 --- /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 0000000..d55f47d --- /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 0000000..72f7920 --- /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 0000000..3d0b57d --- /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 0000000..faa769d --- /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 0000000..5a18e8c --- /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 0000000..be97a00 --- /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 0000000..2de9aba --- /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 0000000..88211d9 --- /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 0000000..1f521b0 --- /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 0000000..50dea92 --- /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 0000000..17d77b4 --- /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 0000000..4f64dc2 --- /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 0000000..b0a57d7 --- /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 0000000..201a22e --- /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 0000000..b5a2e2a --- /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 0000000..c37e2e3 --- /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 0000000..6efca79 --- /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 0000000..5ffb43c --- /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 0000000..616ce7a --- /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 0000000..10e3d2e --- /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 0000000..7036a2c --- /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 0000000..0b267f2 --- /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 0000000..2e66897 --- /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 0000000..e669dcd --- /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 0000000..70b5fb2 --- /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 0000000..25e2ad1 --- /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 0000000..9092237 --- /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 0000000..3d78b17 --- /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 0000000..70666e4 --- /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 0000000..15f0fa1 --- /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 0000000..7c8956e --- /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 0000000..b0f26a5 --- /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 0000000..39902df --- /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 0000000..f6c1305 --- /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 0000000..999f68d --- /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 0000000..1121b82 --- /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 0000000..ac68e63 --- /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 0000000..12ae29a --- /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 0000000..d2af48c --- /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 0000000..2694840 --- /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 0000000..f930df4 --- /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 0000000..9d6fb44 --- /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 0000000..c186f55 --- /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 0000000..5378050 --- /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 0000000..b382455 --- /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 0000000..4364a47 --- /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 0000000..8cf76e5 --- /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 0000000..70c8283 --- /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 0000000..c3abc56 --- /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 0000000..7a4e663 --- /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 0000000..c3ea45a --- /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 0000000..b65c52f --- /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 0000000..123d728 --- /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 0000000..253986e --- /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 0000000..3213f22 --- /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 0000000..1170ebe --- /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 0000000..67d77a1 --- /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 0000000..faa769d --- /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/85] 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 29f81d8..c9db8b2 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 37e4cb9..e4013df 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 3462fb7..8bd8055 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 0000000..c337346 --- /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 0000000..eda726e --- /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 0000000..87a4a3e --- /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 0000000..9f48fa5 --- /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 0000000..761fee8 --- /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 0000000..e84d7c1 --- /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 0000000..2783698 --- /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 0000000..d4e3b9a --- /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 0000000..2eed15c --- /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 0000000..9840ee5 --- /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 0000000..a2ceeb3 --- /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 0000000..e69c0cb --- /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 0000000..8c8f589 --- /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 0000000..333af08 --- /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 0000000..370e40c --- /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 0000000..7ea8430 --- /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 0000000..9fad104 --- /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 0000000..39f2c57 --- /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 0000000..c913005 --- /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 0000000..9750544 --- /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 0000000..6b38bb7 --- /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 0000000..17daab5 --- /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 0000000..4be437e --- /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 0000000..5634cb9 --- /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 0000000..fafbed8 --- /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 0000000..c8aee05 --- /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 0000000..8dd9ff3 --- /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 0000000..4956aaa --- /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 0000000..94efe54 --- /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 0000000..0cc50c9 --- /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 0000000..d55f47d --- /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 0000000..72f7920 --- /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 0000000..3d0b57d --- /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 0000000..faa769d --- /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 0000000..5a18e8c --- /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 0000000..be97a00 --- /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 0000000..2de9aba --- /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 0000000..88211d9 --- /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 0000000..1f521b0 --- /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 0000000..50dea92 --- /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 0000000..17d77b4 --- /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 0000000..4f64dc2 --- /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 0000000..b0a57d7 --- /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 0000000..201a22e --- /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 0000000..b5a2e2a --- /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 0000000..c37e2e3 --- /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 0000000..6efca79 --- /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 0000000..5ffb43c --- /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 0000000..616ce7a --- /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 0000000..10e3d2e --- /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 0000000..7036a2c --- /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 0000000..0b267f2 --- /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 0000000..2e66897 --- /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 0000000..e669dcd --- /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 0000000..70b5fb2 --- /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 0000000..25e2ad1 --- /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 0000000..9092237 --- /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 0000000..3d78b17 --- /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 0000000..70666e4 --- /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 0000000..15f0fa1 --- /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 0000000..7c8956e --- /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 0000000..b0f26a5 --- /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 0000000..39902df --- /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 0000000..f6c1305 --- /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 0000000..999f68d --- /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 0000000..1121b82 --- /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 0000000..ac68e63 --- /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 0000000..12ae29a --- /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 0000000..d2af48c --- /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 0000000..2694840 --- /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 0000000..f930df4 --- /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 0000000..9d6fb44 --- /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 0000000..c186f55 --- /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 0000000..5378050 --- /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 0000000..b382455 --- /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 0000000..4364a47 --- /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 0000000..8cf76e5 --- /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 0000000..70c8283 --- /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 0000000..c3abc56 --- /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 0000000..7a4e663 --- /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 0000000..c3ea45a --- /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 0000000..b65c52f --- /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 0000000..123d728 --- /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 0000000..253986e --- /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 0000000..3213f22 --- /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 0000000..1170ebe --- /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 0000000..67d77a1 --- /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 0000000..cf92a3b --- /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 0000000..faa769d --- /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/85] 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 29f81d8..c9db8b2 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 37e4cb9..e4013df 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 3462fb7..8bd8055 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 0000000..c337346 --- /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 0000000..eda726e --- /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 0000000..87a4a3e --- /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 0000000..9f48fa5 --- /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 0000000..761fee8 --- /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 0000000..e84d7c1 --- /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 0000000..2783698 --- /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 0000000..d4e3b9a --- /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 0000000..2eed15c --- /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 0000000..9840ee5 --- /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 0000000..a2ceeb3 --- /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 0000000..e69c0cb --- /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 0000000..8c8f589 --- /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 0000000..333af08 --- /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 0000000..370e40c --- /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 0000000..7ea8430 --- /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 0000000..9fad104 --- /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 0000000..39f2c57 --- /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 0000000..c913005 --- /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 0000000..9750544 --- /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 0000000..6b38bb7 --- /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 0000000..17daab5 --- /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 0000000..4be437e --- /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 0000000..5634cb9 --- /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 0000000..fafbed8 --- /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 0000000..c8aee05 --- /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 0000000..8dd9ff3 --- /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 0000000..4956aaa --- /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 0000000..94efe54 --- /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 0000000..0cc50c9 --- /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 0000000..d55f47d --- /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 0000000..72f7920 --- /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 0000000..3d0b57d --- /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 0000000..faa769d --- /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 0000000..5a18e8c --- /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 0000000..be97a00 --- /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 0000000..2de9aba --- /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 0000000..88211d9 --- /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 0000000..1f521b0 --- /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 0000000..50dea92 --- /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 0000000..17d77b4 --- /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 0000000..4f64dc2 --- /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 0000000..b0a57d7 --- /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 0000000..201a22e --- /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 0000000..b5a2e2a --- /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 0000000..c37e2e3 --- /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 0000000..6efca79 --- /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 0000000..5ffb43c --- /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 0000000..616ce7a --- /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 0000000..10e3d2e --- /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 0000000..7036a2c --- /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 0000000..0b267f2 --- /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 0000000..2e66897 --- /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 0000000..e669dcd --- /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 0000000..70b5fb2 --- /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 0000000..25e2ad1 --- /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 0000000..9092237 --- /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 0000000..3d78b17 --- /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 0000000..70666e4 --- /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 0000000..15f0fa1 --- /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 0000000..7c8956e --- /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 0000000..b0f26a5 --- /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 0000000..39902df --- /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 0000000..f6c1305 --- /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 0000000..999f68d --- /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 0000000..1121b82 --- /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 0000000..ac68e63 --- /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 0000000..12ae29a --- /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 0000000..d2af48c --- /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 0000000..2694840 --- /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 0000000..f930df4 --- /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 0000000..9d6fb44 --- /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 0000000..c186f55 --- /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 0000000..5378050 --- /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 0000000..b382455 --- /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 0000000..4364a47 --- /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 0000000..8cf76e5 --- /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 0000000..70c8283 --- /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 0000000..c3abc56 --- /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 0000000..7a4e663 --- /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 0000000..c3ea45a --- /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 0000000..b65c52f --- /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 0000000..123d728 --- /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 0000000..253986e --- /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 0000000..3213f22 --- /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 0000000..1170ebe --- /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 0000000..67d77a1 --- /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 0000000..aa619a7 --- /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 0000000..ce3661c --- /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 0000000..801b987 --- /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 0000000..de97487 --- /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 0000000..24a4678 --- /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 0000000..a8b9e81 --- /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 0000000..d3eb3ee --- /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 0000000..0844649 --- /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 0000000..a31931c --- /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 0000000..7d19cf9 --- /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 0000000..334b774 --- /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 0000000..70b4869 --- /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 0000000..ff3b6a3 --- /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 0000000..cf1c742 --- /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 0000000..c1c0ee6 --- /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 0000000..77a302d --- /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 0000000..96e18c5 --- /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 0000000..90e0f18 --- /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 0000000..414b85d --- /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 0000000..ca6d7cd --- /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 0000000..6a5c2d8 --- /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 0000000..fbcfd46 --- /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 0000000..2350d32 --- /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 0000000..ae5cbbf --- /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 0000000..34fbee0 --- /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 0000000..2e21bef --- /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 0000000..ee6f99c --- /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 0000000..6e2ba87 --- /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 0000000..ee1ff95 --- /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 0000000..b5e15c2 --- /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 0000000..8dab0a2 --- /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 0000000..57d2262 --- /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 0000000..b81c36e --- /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 0000000..eacadee --- /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 0000000..6313eb5 --- /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 0000000..a1f8896 --- /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 0000000..76d8943 --- /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 0000000..724fda3 --- /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 0000000..4ca6d77 --- /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 0000000..fd12bc2 --- /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 0000000..b6103a3 --- /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 0000000..8eb9e10 --- /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 0000000..83669f2 --- /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 0000000..ec3f85f --- /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 0000000..5895e5a --- /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 0000000..e1a656d --- /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 0000000..59f1f96 --- /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 0000000..faa769d --- /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/85] 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 801b987..f0f5014 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/85] 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 f0f5014..1bff7be 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/85] 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 1bff7be..8188f4e 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/85] 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 de97487..ac27882 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 24a4678..b1625be 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 8188f4e..5fcfb83 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 a8b9e81..221e035 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 aa619a7..0000000 --- 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 ce3661c..c577424 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 d3eb3ee..cc4cce1 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 0844649..6aef93e 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 a31931c..311e2c1 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 7d19cf9..e068936 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 334b774..11cc898 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 70b4869..1158964 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 cf92a3b..48aba44 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 ff3b6a3..a5f4203 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 cf1c742..a71742f 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 c1c0ee6..3b12add 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 77a302d..df7c0b1 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 96e18c5..eef63c5 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 90e0f18..518b5bd 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 414b85d..2b4003c 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 ca6d7cd..4ffda72 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 6a5c2d8..1e8719d 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 fbcfd46..0dad143 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 ae5cbbf..eca892b 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 34fbee0..08a7f78 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 2e21bef..64ee695 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 ee6f99c..831f504 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 6e2ba87..c7685b3 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 ee1ff95..f752ed0 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 b5e15c2..ce3ecb4 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 8dab0a2..b505083 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 57d2262..4aed93a 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 b81c36e..bd6d76f 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 eacadee..e6cf2ad 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 6313eb5..0c8e13a 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 76d8943..80444b1 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 724fda3..c1e055e 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 4ca6d77..8830a4e 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 fd12bc2..c76e9c1 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 b6103a3..e38ccae 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 8eb9e10..a8f4008 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 83669f2..9ad2f83 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 ec3f85f..4c4c6be 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 5895e5a..3099391 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 e1a656d..5482e80 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 59f1f96..594b186 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/85] 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 0000000..1a2f0ef --- /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 0000000..cf3e975 --- /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 0000000..6bdc509 --- /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 0000000..3e7bb8a --- /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 0000000..7912ad5 --- /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 0000000..d47342d --- /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 0000000..97ffe13 --- /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 0000000..5292c8b --- /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 0000000..32491a6 --- /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 0000000..515abad --- /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 0000000..91b9927 --- /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 0000000..1f7be51 --- /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 0000000..0a0ac1a --- /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 0000000..eefeaf9 --- /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 0000000..4d0f93b --- /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 0000000..1b2b6c2 --- /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 0000000..a86aa1f --- /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 0000000..3fedc9b --- /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 0000000..35c1d00 --- /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 0000000..e1f6b0b --- /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 0000000..b78589b --- /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 0000000..13ef3ba --- /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 0000000..2d76eee --- /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 0000000..56b1968 --- /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 0000000..04b6d50 --- /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 0000000..da9d9cf --- /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 0000000..9915b6d --- /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 0000000..3fc9978 --- /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 0000000..4b2c5ee --- /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 0000000..e7005b2 --- /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 0000000..8be0b6b --- /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 0000000..f971ba5 --- /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 0000000..59062ae --- /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 0000000..7b51b48 --- /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 0000000..b26b5cd --- /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 0000000..01abbcc --- /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 0000000..e3901be --- /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 0000000..8c5ed6d --- /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 0000000..87c9232 --- /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 0000000..38c8a37 --- /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 0000000..fa2a256 --- /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 0000000..7dc188d --- /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 0000000..ed1a5ee --- /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 0000000..3733267 --- /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 0000000..f85da96 --- /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 0000000..452255a --- /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 0000000..1a94ead --- /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 0000000..34414dd --- /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 0000000..6c7eca5 --- /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 0000000..89701e7 --- /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 0000000..59d1a87 --- /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 0000000..11e27d2 --- /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 0000000..786155d --- /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 0000000..6e91517 --- /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 0000000..b0a2643 --- /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 0000000..3535c61 --- /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 0000000..9e5d00d --- /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 0000000..164618c --- /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 0000000..57717ca --- /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 0000000..80c4bf9 --- /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 0000000..9c9fe36 --- /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 0000000..074cfe7 --- /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 0000000..0268884 --- /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 0000000..dacff54 --- /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 0000000..e790dc1 --- /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 0000000..b567de0 --- /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 0000000..fd739fd --- /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 0000000..198a29e --- /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 0000000..7608319 --- /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 0000000..d49efc4 --- /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 0000000..067834c --- /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 0000000..7759387 --- /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 0000000..26db37a --- /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 0000000..50c29f9 --- /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 0000000..2d50fbd --- /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 0000000..89de8ed --- /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 0000000..dd86901 --- /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 0000000..6540434 --- /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 0000000..fcd8302 --- /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 0000000..254f8e5 --- /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 0000000..21d9320 --- /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 0000000..a1dcbc4 --- /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 0000000..2b67d71 --- /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 0000000..f291d8d --- /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 0000000..91842c7 --- /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 0000000..dab88d9 --- /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 0000000..96927ab --- /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 0000000..135eb46 --- /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 0000000..7ea7ba8 --- /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 0000000..c0678ac --- /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 0000000..f33dfd1 --- /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 0000000..a81e092 --- /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 0000000..caf3ef2 --- /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 0000000..d82c697 --- /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 0000000..5285c79 --- /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 0000000..f9e9903 --- /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 0000000..a1315d5 --- /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 0000000..f1fb40b --- /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 0000000..ee583b5 --- /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 0000000..7b8195e --- /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 0000000..1b54e8e --- /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 0000000..5c14c52 --- /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 0000000..e7296ed --- /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 0000000..29221c5 --- /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 0000000..37ac77c --- /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 0000000..247f6f5 --- /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 0000000..af14c16 --- /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 0000000..52d6bdd --- /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 0000000..ba91820 --- /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 0000000..a11c08e --- /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 0000000..c12f55c --- /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 0000000..4d2cf2c --- /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 0000000..01805f5 --- /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 0000000..5f259d4 --- /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 0000000..a74f599 --- /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 0000000..319affc --- /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 0000000..34bcd14 --- /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 0000000..49d09c0 --- /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 0000000..15a5d27 --- /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 0000000..62951e1 --- /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 0000000..d6ee12c --- /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 0000000..51cd7c5 --- /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 0000000..f288ef0 --- /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 0000000..475c963 --- /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 0000000..64b1feb --- /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 0000000..a845bc1 --- /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 0000000..d88c00c --- /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 0000000..dc539f5 --- /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 0000000..1706ad8 --- /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 0000000..4b9b0c0 --- /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 0000000..ac2b4d5 --- /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 0000000..174b8c6 --- /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 0000000..d8d7978 --- /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 0000000..3ec3748 --- /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 0000000..86febed --- /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 0000000..f7e5aa2 --- /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 0000000..408d60e --- /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 0000000..f5a02da --- /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 0000000..42d7ca4 --- /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 0000000..1e8aa80 --- /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 0000000..f5cbb1e --- /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 0000000..c025339 --- /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 0000000..13c6d36 --- /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 0000000..dd70772 --- /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 0000000..f88c792 --- /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 0000000..adc42a7 --- /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 0000000..4fdc185 --- /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 0000000..1b09001 --- /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 0000000..2e28ee6 --- /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 0000000..639331a --- /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 0000000..d8f17b8 --- /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 0000000..063309c --- /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 0000000..e62352d --- /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 0000000..851741a --- /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 0000000..96471ba --- /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 0000000..921e674 --- /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 0000000..8c06a34 --- /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 0000000..656c35d --- /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 0000000..bd8b4eb --- /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 0000000..cbf2dcd --- /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 0000000..e087864 --- /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 0000000..db511f8 --- /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 0000000..236791b --- /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 0000000..a41eca6 --- /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 0000000..d8a6bb2 --- /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 0000000..79612ca --- /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 0000000..7c93bf5 --- /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 0000000..1e88c35 --- /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 0000000..eb5837e --- /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 0000000..3b9a3fb --- /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 0000000..86d2eee --- /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 0000000..dbe3cfb --- /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 0000000..ce4e580 --- /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 0000000..3921584 --- /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 0000000..e065b04 --- /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 0000000..834e380 --- /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 0000000..b89b60b --- /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 0000000..c8588de --- /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 0000000..44441ee --- /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 0000000..aabe520 --- /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 0000000..6199175 --- /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 0000000..0b9ab73 --- /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 0000000..49df7e7 --- /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 0000000..169234d --- /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 0000000..5671e3c --- /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 0000000..d0ee0a6 --- /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 0000000..558160d --- /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 0000000..fddeafd --- /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 0000000..3a686c3 --- /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 0000000..14f2c7a --- /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 0000000..1c6e7c9 --- /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 0000000..f6666bb --- /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 0000000..8902d44 --- /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 0000000..295563d --- /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 0000000..a90830b --- /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 0000000..5cc2efc --- /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 0000000..2376ba9 --- /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 0000000..415e130 --- /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 0000000..674d640 --- /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 0000000..12e5464 --- /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 0000000..c1c437a --- /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 0000000..fcd4a80 --- /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 0000000..64a5da3 --- /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 0000000..644aeff --- /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 0000000..b717d7e --- /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 0000000..a8a40a6 --- /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 0000000..1c910b7 --- /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 0000000..9b44e6e --- /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 0000000..fbdf286 --- /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/85] 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 0000000..423ffb7 --- /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 0000000..7233734 --- /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 0000000..947cd81 --- /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 0000000..a2d07d2 --- /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 0000000..55af7a8 --- /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 0000000..049eee6 --- /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 0000000..0f3b915 --- /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 0000000..4bcc527 --- /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 0000000..b4f3575 --- /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 0000000..baa3134 --- /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 0000000..1e1ed4a --- /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 0000000..ee3c106 --- /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 0000000..a237736 --- /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 0000000..8d0d4a9 --- /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 0000000..1be6db1 --- /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 0000000..b04cf2f --- /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 0000000..72d2102 --- /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 0000000..abc1629 --- /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 0000000..2dfc57e --- /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 0000000..5d37a2e --- /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 0000000..75ccfaa --- /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 0000000..01d83bc --- /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 0000000..b4acfb3 --- /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 0000000..81824f6 --- /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 0000000..d42d8fa --- /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 0000000..795c4aa --- /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 0000000..a591a7e --- /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 0000000..579a3db --- /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 0000000..76a01a0 --- /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/85] 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 55af7a8..f9701b1 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 049eee6..78758e6 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 579a3db..175c823 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 76a01a0..df25bee 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/85] 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 947cd81..74314e9 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 0000000..39e6fd5 --- /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 0000000..543b3dc --- /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 0000000..da87866 --- /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 0000000..e58a6b3 --- /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 0000000..9490f2e --- /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 0000000..892913a --- /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 0000000..6ec4e62 --- /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 0000000..fd3a376 --- /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 0000000..1d51ee0 --- /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 0000000..823aad7 --- /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 0000000..0def49c --- /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 0000000..5de009a --- /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 0000000..72b6a66 --- /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 0000000..2a79264 --- /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 0000000..4c09ad5 --- /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 0000000..c1c6d3a --- /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 0000000..8606adc --- /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 0000000..8f78dcc --- /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 0000000..16ff8c4 --- /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 0000000..bb39029 --- /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 0000000..0d3ae77 --- /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 0000000..1bf4c7e --- /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 0000000..3b1afff --- /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 0000000..c54202d --- /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 0000000..2f85430 --- /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 0000000..16617c1 --- /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 0000000..68e500a --- /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 0000000..9ce2fe0 --- /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 0000000..8195ba8 --- /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 0000000..702c09b --- /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/85] 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 0000000..0d9d8fd --- /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 0000000..488fe9d --- /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 0000000..f243c77 --- /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 0000000..8965ef3 --- /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 0000000..45867c9 --- /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 0000000..a804310 --- /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 0000000..3944d50 --- /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 0000000..0f95379 --- /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 0000000..4b6e6fa --- /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 0000000..2857e24 --- /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 0000000..9a4e3cd --- /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 0000000..773678f --- /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 0000000..a1e2278 --- /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 0000000..8d5a8a3 --- /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 0000000..726733b --- /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 0000000..2fdb955 --- /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/85] 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 0000000..1191115 --- /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 0000000..d966d02 --- /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 0000000..c7fcccf --- /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 0000000..1b33325 --- /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 0000000..5c96c56 --- /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 0000000..87973d6 --- /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 0000000..d7ba954 --- /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 0000000..e1947b0 --- /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 0000000..d40ebe5 --- /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 0000000..8828a3f --- /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 0000000..7459c95 --- /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 0000000..7f295d2 --- /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 0000000..0321205 --- /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/85] 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 1191115..5d9beb7 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/85] 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 d966d02..2f9ffb8 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/85] 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 2f9ffb8..6d4d41a 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 c7fcccf..87e0b9d 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 1b33325..0511767 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 5c96c56..7f5bb70 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 87973d6..f771119 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 d7ba954..4738e00 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 e1947b0..ac927e5 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 d40ebe5..c45fd47 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 8828a3f..374ba14 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 7459c95..f46de3a 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 7f295d2..0880883 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 0321205..2b7ce64 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/85] 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 5d9beb7..1191115 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 6d4d41a..82f2536 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/85] 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 82f2536..5ff5940 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/85] 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 1191115..6cac062 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 5ff5940..089ca96 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/85] 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 0000000..c923d4b --- /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 0000000..eeb0f8e --- /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 0000000..62be667 --- /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 0000000..047e023 --- /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 0000000..d879bb2 --- /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 0000000..2c5ceed --- /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 0000000..5671f7c --- /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 0000000..2eb8ada --- /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 0000000..dc5ce76 --- /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 0000000..5edc3e6 --- /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 0000000..faca42f --- /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 0000000..e98d363 --- /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 0000000..729b3b7 --- /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 0000000..f89534b --- /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 0000000..49a8ac1 --- /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 0000000..20d5709 --- /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 0000000..42cf9fa --- /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 0000000..96a658d --- /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 0000000..993ea37 --- /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 0000000..9dd87a2 --- /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 0000000..4ac8174 --- /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 0000000..d8066dd --- /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 0000000..d04f0dd --- /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 0000000..8508593 --- /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 0000000..a00b773 --- /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 0000000..a4d8260 --- /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 0000000..9266487 --- /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 0000000..35dbd1d --- /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 0000000..daee5f4 --- /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 0000000..2c5e648 --- /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 0000000..b66af29 --- /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 0000000..61f382e --- /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 0000000..383c711 --- /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 0000000..63db819 --- /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 0000000..fc3ca84 --- /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 0000000..89b7435 --- /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 0000000..c84fac1 --- /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 0000000..3017642 --- /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 0000000..40fd423 --- /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 0000000..6b8a080 --- /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 0000000..e67eff8 --- /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 0000000..fc46d59 --- /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 0000000..f6114e8 --- /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 0000000..d93b80b --- /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 0000000..e457cfe --- /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 0000000..ae29a92 --- /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 0000000..507a2c2 --- /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 0000000..491c46d --- /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 0000000..a45e4f1 --- /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 0000000..78d0bd3 --- /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 0000000..1774333 --- /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 0000000..e017fac --- /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 0000000..6f58108 --- /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 0000000..79ed2b7 --- /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 0000000..fdaf876 --- /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 0000000..b9b1e6b --- /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 0000000..f1191af --- /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 0000000..a2d1447 --- /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 0000000..4d7ae64 --- /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 0000000..e0609ac --- /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 0000000..d3c4e8b --- /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 0000000..6119460 --- /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 0000000..149be4c --- /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 0000000..91eed2e --- /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 0000000..9ff9520 --- /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 0000000..451db02 --- /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 0000000..84fa972 --- /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 0000000..cad5cab --- /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 0000000..79bc394 --- /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/85] 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 62be667..97d6751 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 047e023..13a80f3 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 5671f7c..966abd6 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 2eb8ada..5113f4b 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/85] 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 0000000..8bd0d38 --- /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 0000000..f027539 --- /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 0000000..0549639 --- /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 0000000..3eac18b --- /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 0000000..e4209ef --- /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 0000000..ef2ccb4 --- /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 0000000..e40908f --- /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 0000000..c0612cb --- /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 0000000..6cd39a1 --- /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 0000000..ea5b69b --- /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 0000000..2a5fd4a --- /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 0000000..9c4db4c --- /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 0000000..b8479b2 --- /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 0000000..48eea8e --- /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 0000000..ebf4103 --- /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 0000000..31cd0a2 --- /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 0000000..c754d03 --- /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 0000000..c2f831b --- /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 0000000..cdbb2bf --- /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 0000000..df2eade --- /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 0000000..e81bb71 --- /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 0000000..ef9982c --- /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 0000000..7d4c8d6 --- /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 0000000..fd9fa51 --- /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 0000000..37e5cbb --- /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 0000000..69335b1 --- /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 0000000..432b3c1 --- /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 0000000..355e362 --- /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 0000000..60eb000 --- /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 0000000..c4e762b --- /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 0000000..8dde614 --- /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 0000000..3811276 --- /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 0000000..b7c6938 --- /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 0000000..00632a6 --- /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 0000000..34bf17a --- /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 0000000..80b63dd --- /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 0000000..24190bd --- /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 0000000..52d8c03 --- /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/85] 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 0000000..9dad8cc --- /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/85] 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 0000000..a3c5d1b --- /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 0000000..51550e9 --- /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 0000000..b1bbef9 --- /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 0000000..5974eb0 --- /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 0000000..7af70e6 --- /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 0000000..f2be3e3 --- /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 0000000..3910e98 --- /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 0000000..0eaefe3 --- /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 0000000..01fb36f --- /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 0000000..600d36e --- /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 0000000..267ea97 --- /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 0000000..3c846c3 --- /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/85] 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 0000000..0bca8a2 --- /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/85] 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 0000000..c46aaac --- /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 0000000..ba60ef9 --- /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 0000000..3d0ba9e --- /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 0000000..a5c44af --- /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 0000000..8274396 --- /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 0000000..3e034e0 --- /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 0000000..f311195 --- /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 0000000..534c0d3 --- /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 0000000..cd03521 --- /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 0000000..887d05b --- /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 0000000..54d0bc0 --- /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 0000000..f1bfdbf --- /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 0000000..8778d45 --- /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 0000000..58d772a --- /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 0000000..973b3cb --- /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 0000000..a8c5b30 --- /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 0000000..1abf1b0 --- /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 0000000..ba25d50 --- /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 0000000..e9bf86c --- /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 0000000..5b0d898 --- /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 0000000..5207799 --- /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 0000000..237e480 --- /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 0000000..bc9ff5f --- /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 0000000..d30dfb4 --- /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 0000000..5cf0571 --- /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 0000000..8de1cec --- /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 0000000..cecbbc3 --- /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 0000000..77ced97 --- /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 0000000..5655481 --- /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 0000000..7fd9ea5 --- /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 0000000..146ef2a --- /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 0000000..2060a80 --- /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 0000000..a9444f7 --- /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 0000000..5eec5b7 --- /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 0000000..b913be3 --- /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 0000000..a570bd7 --- /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 0000000..8b1bbcf --- /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 0000000..10ce675 --- /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 0000000..1ece974 --- /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 0000000..d584083 --- /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 0000000..251bf52 --- /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 0000000..2f3b8d7 --- /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 0000000..8130416 --- /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 0000000..d8ae9b9 --- /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 0000000..d1e3f25 --- /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 0000000..74e4d6e --- /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 0000000..f248a9a --- /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 0000000..41b48f7 --- /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 0000000..2002231 --- /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 0000000..0cdd168 --- /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 0000000..c186066 --- /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 0000000..33dc9e7 --- /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 0000000..81372e8 --- /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 0000000..fb8f516 --- /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 0000000..8436f04 --- /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 0000000..178fd93 --- /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 0000000..4c90d2d --- /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 0000000..166009d --- /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 0000000..9ba6ffe --- /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 0000000..888e824 --- /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 0000000..5594665 --- /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 0000000..f2890e1 --- /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 0000000..2622b95 --- /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 0000000..5ff333f --- /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 0000000..901357e --- /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 0000000..3c92714 --- /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 0000000..b473c5d --- /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 0000000..1366b99 --- /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 0000000..f8460ce --- /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 0000000..81e2599 --- /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 0000000..8c93a50 --- /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 0000000..5da287c --- /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 0000000..a1ec4b9 --- /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 0000000..38da0b5 --- /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 0000000..8aabe58 --- /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 0000000..31dd7a4 --- /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 0000000..63962fa --- /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 0000000..6ef2346 --- /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 0000000..42ed2f7 --- /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 0000000..5c56dc0 --- /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 0000000..15ec234 --- /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 0000000..428bc99 --- /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 0000000..e1e33cb --- /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 0000000..fe61fcc --- /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 0000000..d445022 --- /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 0000000..fea3054 --- /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 0000000..290cf08 --- /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 0000000..87c9c94 --- /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 0000000..75f0b9d --- /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 0000000..442862f --- /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 0000000..d809a83 --- /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 0000000..61e9a38 --- /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 0000000..7d9f06d --- /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 0000000..9c3be55 --- /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 0000000..bcc861d --- /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 0000000..e709ff7 --- /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 0000000..ae4bf4e --- /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 0000000..0bfff15 --- /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 0000000..bf320ff --- /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 0000000..36fe629 --- /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 0000000..8030d56 --- /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 0000000..d169054 --- /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 0000000..6219d33 --- /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 0000000..65d6d9e --- /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 0000000..197f335 --- /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 0000000..6a2faff --- /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 0000000..df5b10b --- /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 0000000..31bc700 --- /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 0000000..1bda458 --- /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 0000000..892c99c --- /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 0000000..d2ae124 --- /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 0000000..256c249 --- /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 0000000..66eae65 --- /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 0000000..9ef30bc --- /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 0000000..cf9b24c --- /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 0000000..a7bfded --- /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 0000000..fc6b368 --- /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 0000000..ca00b66 --- /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 0000000..f854704 --- /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 0000000..5bd647c --- /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 0000000..fe3d88d --- /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 0000000..0bb3b44 --- /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 0000000..97db543 --- /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 0000000..5c1a50f --- /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 0000000..58e21ad --- /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 0000000..6f96b70 --- /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 0000000..75c84ed --- /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 0000000..adfe684 --- /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 0000000..71d8385 --- /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 0000000..bcb8d30 --- /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 0000000..f3d2d2d --- /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 0000000..2fd8e14 --- /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 0000000..6670a23 --- /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 0000000..cab59ca --- /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 0000000..355c129 --- /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 0000000..7ca8c28 --- /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 0000000..d21dbb5 --- /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 0000000..d3d62c0 --- /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 0000000..c1b101a --- /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 0000000..23fb5ad --- /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 0000000..65e7198 --- /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 0000000..ea06edf --- /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 0000000..3efec07 --- /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 0000000..1cbe342 --- /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 0000000..82f67ee --- /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 0000000..8691e98 --- /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 0000000..fd37043 --- /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 0000000..5e0b14b --- /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 0000000..5eace82 --- /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 0000000..1feb4cc --- /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 0000000..17d1fd6 --- /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 0000000..f77a2a3 --- /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 0000000..1ae7d87 --- /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 0000000..6f4942b --- /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 0000000..5698cf2 --- /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 0000000..f35d1ad --- /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 0000000..d073396 --- /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 0000000..8a3c72d --- /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 0000000..bd312b7 --- /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 0000000..7441559 --- /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 0000000..ae16199 --- /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 0000000..f5e1bbc --- /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 0000000..f1770d8 --- /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 0000000..42e1909 --- /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 0000000..520584f --- /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 0000000..57c4782 --- /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 0000000..62a7a74 --- /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 0000000..727c7ec --- /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 0000000..0749d08 --- /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 0000000..25fe5b6 --- /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 0000000..8acc61f --- /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 0000000..4f9c82a --- /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 0000000..2b250c1 --- /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 0000000..1eaa419 --- /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 0000000..0de6215 --- /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 0000000..27de673 --- /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 0000000..eee23a4 --- /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 0000000..cfba6f5 --- /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 0000000..6196bce --- /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 0000000..2adc8eb --- /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 0000000..2453981 --- /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 0000000..d5e1a53 --- /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 0000000..08c4e30 --- /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 0000000..e9a533b --- /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 0000000..1a4bfc5 --- /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 0000000..bcd84e2 --- /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 0000000..6b73fa4 --- /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 0000000..127aeca --- /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 0000000..3bb13b7 --- /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 0000000..a1fc50b --- /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 0000000..24a1188 --- /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 0000000..deda81e --- /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 0000000..ba3ad76 --- /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 0000000..306f9b4 --- /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 0000000..74163ff --- /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 0000000..d30fa7a --- /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 0000000..aa0ab24 --- /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 0000000..c2d0891 --- /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 0000000..2979429 --- /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 0000000..0d429ec --- /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 0000000..ceb0a28 --- /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 0000000..cad0a5a --- /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 0000000..f4df250 --- /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 0000000..7a948d8 --- /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 0000000..beaf4be --- /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 0000000..0fcbe63 --- /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 0000000..a5ab8b2 --- /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 0000000..8396297 --- /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 0000000..1830243 --- /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 0000000..1a1db10 --- /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 0000000..b18129b --- /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 0000000..06dea31 --- /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 0000000..2c26362 --- /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 0000000..8783fca --- /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 0000000..3bff712 --- /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 0000000..966a3ff --- /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 0000000..52ebc89 --- /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 0000000..a56db53 --- /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/85] 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 0000000..1b8ff7c --- /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 0000000..0a0f78f --- /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 0000000..94b445d --- /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 0000000..7945d7b --- /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 0000000..5d292d0 --- /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 0000000..4ce84e6 --- /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 0000000..3911415 --- /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 0000000..4180470 --- /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 0000000..4a94932 --- /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 0000000..ec9cba4 --- /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 0000000..da50193 --- /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 0000000..980e155 --- /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 0000000..aaf70cb --- /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 0000000..78a2faf --- /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 0000000..0263e08 --- /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 0000000..a4aeda8 --- /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 0000000..cda4a75 --- /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 0000000..f7f03cf --- /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 0000000..02c6f2b --- /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 0000000..1ac2e3d --- /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 0000000..e228540 --- /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 0000000..28b0cc7 --- /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/85] 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 0000000..83d5962 --- /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 0000000..96c8076 --- /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 0000000..9c5a443 --- /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 0000000..bec4c46 --- /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 0000000..c34dff3 --- /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 0000000..9fba5d5 --- /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 0000000..a53ff23 --- /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 0bca8a2..6552d7a 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 0000000..a59493a --- /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 0000000..77ab90d --- /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 0000000..22cee7d --- /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 0000000..614641b --- /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 0000000..38672b7 --- /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 0000000..d110835 --- /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 0000000..e988acc --- /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 0000000..5590710 --- /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 0000000..fe4969c --- /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 0000000..b0337e7 --- /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 0000000..fb1b8c8 --- /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 0000000..975dee7 --- /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 0000000..0623ce3 --- /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 0000000..f7acb51 --- /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 0000000..bcbaa43 --- /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 0000000..11be1d4 --- /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 0000000..55a6f68 --- /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 0000000..1794e8d --- /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 0000000..e273837 --- /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 0000000..ccd71e0 --- /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/85] 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 0000000..83d5962 --- /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 0000000..96c8076 --- /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 0000000..9c5a443 --- /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 0000000..bec4c46 --- /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 0000000..c34dff3 --- /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 0000000..9fba5d5 --- /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 0000000..a53ff23 --- /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 0bca8a2..6552d7a 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 0000000..a59493a --- /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 0000000..77ab90d --- /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 0000000..22cee7d --- /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 0000000..614641b --- /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 0000000..38672b7 --- /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 0000000..d110835 --- /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 0000000..e988acc --- /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 0000000..5590710 --- /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 0000000..fe4969c --- /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 0000000..b0337e7 --- /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 0000000..fb1b8c8 --- /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 0000000..975dee7 --- /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 0000000..0623ce3 --- /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 0000000..f7acb51 --- /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 0000000..bcbaa43 --- /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 0000000..11be1d4 --- /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 0000000..55a6f68 --- /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 0000000..1794e8d --- /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 0000000..e273837 --- /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 0000000..ccd71e0 --- /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/85] 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 0000000..5208a77 --- /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 0000000..05888fb --- /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 0000000..7e44d26 --- /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 0000000..ff85fc8 --- /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 0000000..a475ee8 --- /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 0000000..afb37c3 --- /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 0000000..2b4fca1 --- /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 0000000..9986303 --- /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 0000000..eaa7a27 --- /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 0000000..2b710a8 --- /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 0000000..b787170 --- /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 0000000..aa4b20b --- /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 0000000..2979820 --- /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 0000000..435e7b3 --- /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 0000000..e5ad217 --- /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 0000000..479578f --- /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 0000000..888330d --- /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/85] 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 0000000..fb50996 --- /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 0000000..bdc533d --- /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 0000000..eab3c61 --- /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 0000000..19c40c4 --- /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 0000000..b1cd285 --- /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 0000000..be7ffb9 --- /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 0000000..2c466df --- /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 0000000..bd38b04 --- /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 0000000..9ce975b --- /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 0000000..bb2eb80 --- /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 0000000..4a45a6e --- /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 0000000..2eb53fe --- /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 0000000..8e61bc6 --- /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 0000000..c000222 --- /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 0000000..0cf847e --- /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 0000000..04bf458 --- /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 0000000..509e215 --- /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 0000000..f249899 --- /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 0000000..b9b9bd2 --- /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 0000000..cd62a13 --- /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 0000000..665b41d --- /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 0000000..fa5895a --- /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 0000000..360fb8c --- /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 0000000..1095047 --- /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 0000000..42e2a55 --- /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 0000000..df98cae --- /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 0000000..57a4aca --- /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 0000000..09ee29a --- /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 0000000..1c4d237 --- /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 0000000..3e0853a --- /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 0000000..3c8d5df --- /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 0000000..79995d7 --- /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 0000000..29c0ec3 --- /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 0000000..fbb529c --- /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 0000000..8e669ff --- /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 0000000..c112735 --- /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 0000000..7dd05a5 --- /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 0000000..f5881ae --- /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 0000000..b7baf3a --- /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 0000000..8968060 --- /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 0000000..01b1533 --- /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 0000000..75e5724 --- /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 0000000..281b511 --- /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 0000000..e147cdd --- /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 0000000..588d3cd --- /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 0000000..77d7063 --- /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 0000000..55da68a --- /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 0000000..1d279f9 --- /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 0000000..0e21405 --- /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 0000000..c825702 --- /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 0000000..ab1bb62 --- /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 0000000..e8dfd3a --- /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 0000000..60a78a7 --- /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 0000000..4bda6a0 --- /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 0000000..b7cbddc --- /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 0000000..53dbbaa --- /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 0000000..c69c8f5 --- /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 0000000..5678cdd --- /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 0000000..97d83a5 --- /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 0000000..bbac551 --- /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 0000000..e505e0d --- /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 0000000..286cecd --- /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 0000000..0f71ff8 --- /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 0000000..9725181 --- /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 0000000..12a6acf --- /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 0000000..b2eae25 --- /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 0000000..b55ea90 --- /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 0000000..2680648 --- /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 0000000..69079bf --- /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 0000000..b52445d --- /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 0000000..271e76b --- /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 0000000..654437e --- /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 0000000..d017ec0 --- /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 0000000..b136462 --- /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 0000000..5114938 --- /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 0000000..f9aa9c6 --- /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 0000000..ca73b00 --- /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 0000000..43fb5f8 --- /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 0000000..257df59 --- /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 0000000..272a204 --- /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 0000000..e107b36 --- /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 0000000..898d6c2 --- /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 0000000..d133203 --- /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 0000000..9637dc6 --- /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 0000000..5483ed4 --- /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 0000000..8058025 --- /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 0000000..7aa47c2 --- /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 0000000..604ad3e --- /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 0000000..fd034ab --- /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 0000000..56c5b18 --- /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 0000000..9e5043a --- /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 0000000..0c648c5 --- /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 0000000..bf37ff3 --- /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 0000000..9fe58a7 --- /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 0000000..1bf4c45 --- /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 0000000..bd6c371 --- /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 0000000..77f9cdb --- /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 0000000..8be09ba --- /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 0000000..68cb455 --- /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 0000000..725689b --- /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 0000000..9b49983 --- /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 0000000..5f1fb08 --- /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 0000000..53d7782 --- /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 0000000..ea3926c --- /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 0000000..bc70045 --- /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 0000000..09ec0af --- /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 0000000..e579846 --- /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 0000000..0c431a6 --- /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 0000000..c1c5c93 --- /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 0000000..5fae0f6 --- /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 0000000..184f623 --- /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 0000000..b5ba735 --- /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 0000000..36ed5f0 --- /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 0000000..cac2c91 --- /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 0000000..9a1050e --- /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 0000000..05b856a --- /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 0000000..7e1fd49 --- /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 0000000..468a516 --- /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 0000000..f4c32c1 --- /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 0000000..2bb7c85 --- /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 0000000..7b1c5db --- /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 0000000..a1bc50a --- /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 0000000..7d586d0 --- /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 0000000..caa81fd --- /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 0000000..b6660fd --- /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 0000000..8a1390f --- /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 0000000..69f01f1 --- /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 0000000..e0d446c --- /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 0000000..3545628 --- /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 0000000..fc31d39 --- /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 0000000..c05229b --- /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 0000000..dae2774 --- /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 0000000..49c522f --- /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 0000000..5d04e1e --- /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 0000000..becd3b1 --- /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 0000000..b661d71 --- /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 0000000..35d1a39 --- /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 0000000..d4f9733 --- /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 0000000..866271d --- /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 0000000..161178c --- /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 0000000..51dd063 --- /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 0000000..ab2ca4e --- /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 0000000..0967977 --- /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 0000000..c567175 --- /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 0000000..49db2ca --- /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 0000000..1c2abd9 --- /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 0000000..8687a45 --- /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 0000000..e08050b --- /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 0000000..8e3f551 --- /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 0000000..9b71d72 --- /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 0000000..967c64d --- /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 0000000..2897040 --- /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 0000000..c29c0c6 --- /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 0000000..d2822bc --- /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 0000000..3b75263 --- /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 0000000..0c7719f --- /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 0000000..39cade2 --- /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 0000000..a73215c --- /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 0000000..5fdc342 --- /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 0000000..40be865 --- /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 0000000..6134bb6 --- /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 0000000..3dd1ef8 --- /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 0000000..e1c4775 --- /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 0000000..b316c52 --- /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 0000000..fede2a4 --- /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 0000000..5b64600 --- /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 0000000..a5849e8 --- /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 0000000..71b3d07 --- /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 0000000..e13ea2c --- /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 0000000..22dba59 --- /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 0000000..1262514 --- /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 0000000..1c33d6e --- /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 0000000..3984512 --- /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 0000000..619a36e --- /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 0000000..e97d8bb --- /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 0000000..758971d --- /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 0000000..68068d2 --- /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 0000000..df97f3e --- /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 0000000..82487ed --- /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 0000000..4459944 --- /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 0000000..d0b58ee --- /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 0000000..7ae9704 --- /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 0000000..052c6b8 --- /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 0000000..92da693 --- /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 0000000..60188bd --- /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 0000000..f6e9618 --- /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 0000000..75eff04 --- /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 0000000..d53a0c8 --- /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 0000000..8086bc7 --- /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 0000000..d904830 --- /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 0000000..90204e2 --- /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 0000000..940e02b --- /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 0000000..552f21c --- /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 0000000..4c9daeb --- /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 0000000..a781b2d --- /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 0000000..acc89ca --- /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 0000000..aa650e9 --- /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 0000000..6f44e5d --- /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 0000000..95fb2e0 --- /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 0000000..53c448f --- /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 0000000..8133789 --- /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 0000000..5f1b6e8 --- /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 0000000..bd4aa23 --- /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 0000000..e770273 --- /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 0000000..23985e9 --- /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 0000000..5cf04f4 --- /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 0000000..b446b99 --- /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 0000000..836bb18 --- /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 0000000..dbbdee4 --- /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 0000000..c113735 --- /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 0000000..f369525 --- /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 0000000..82c7ddf --- /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 0000000..719c3f7 --- /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 0000000..d71d0d4 --- /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 0000000..fef3580 --- /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 0000000..a7bf9c3 --- /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 0000000..baae863 --- /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 0000000..8b0172f --- /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 0000000..70ae974 --- /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 0000000..124bfcb --- /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 0000000..4e8a3fa --- /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 0000000..9d16919 --- /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 0000000..1f90ae5 --- /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 0000000..693dd47 --- /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 0000000..56bd062 --- /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 0000000..6f0c7fc --- /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 0000000..13a6af0 --- /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 0000000..5462c0a --- /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 0000000..2d33844 --- /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 0000000..c57dea8 --- /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 0000000..e2e4793 --- /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 0000000..09f4afd --- /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 0000000..8d0e174 --- /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 0000000..6009f8f --- /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 0000000..7005107 --- /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 0000000..5be5d11 --- /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 0000000..4ea14c0 --- /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 0000000..cf7c000 --- /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 0000000..50fbe05 --- /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 0000000..ad278b7 --- /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 0000000..df90449 --- /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 0000000..b4e268a --- /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/85] 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 124bfcb..88cd95b 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 4e8a3fa..abb5f50 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 9d16919..7128ab3 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 1f90ae5..c2f57eb 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 693dd47..696bee8 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 56bd062..dbaf65e 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 6f0c7fc..0c60b5e 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 13a6af0..155b6fc 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 5462c0a..47886fb 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 2d33844..6abdc34 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 c57dea8..23ef097 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 e2e4793..0f10c84 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 09f4afd..da4e1ba 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 ad278b7..9afd985 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 df90449..599ec4a 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 b4e268a..6b00e24 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/85] 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 0000000..eea042a --- /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 0000000..37fc32e --- /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 0000000..8778643 --- /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 0000000..98abbcd --- /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 83d5962..cc37c2c 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 96c8076..750689d 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 9c5a443..b438ee2 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 bec4c46..54e5816 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 5208a77..e8c9701 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 05888fb..50364c1 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 7e44d26..67c2dfc 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 ff85fc8..5da2f88 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 a475ee8..a53fa63 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 afb37c3..8973f94 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 2b4fca1..bfd59a0 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 9986303..10cb563 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 eaa7a27..4bdcc73 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 2b710a8..67e9b19 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 b787170..1681866 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 aa4b20b..110bad9 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 2979820..84efc9d 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 435e7b3..32076c5 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 e5ad217..71f6604 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 479578f..fbec420 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 888330d..0473269 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 c34dff3..0ea1c62 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 9fba5d5..06015f9 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 a53ff23..14013ed 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 6552d7a..ec0aa54 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 a59493a..f95674c 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 77ab90d..d9e99b3 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 22cee7d..4e7460a 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 614641b..8488996 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 38672b7..07f9079 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 d110835..f6bbc7b 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 e988acc..5f1a78c 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 5590710..df8ced5 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 fe4969c..3ea4da2 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 b0337e7..89a553b 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 fb1b8c8..4168ec6 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 975dee7..d7fb596 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 0623ce3..732d929 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 f7acb51..3e6bc79 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 bcbaa43..8aea514 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 11be1d4..8bdf5a4 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 55a6f68..90a215c 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 1794e8d..49d8e5a 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 e273837..9a05e99 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 ccd71e0..093bdc9 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/85] 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 0000000..50f3a1c --- /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 0000000..79d61ec --- /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 0000000..23810c9 --- /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 0000000..8128b9a --- /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 0000000..95c75c3 --- /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 0000000..dc6a848 --- /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 0000000..9ee90e1 --- /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 0000000..0de5019 --- /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 0000000..a6465de --- /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 0000000..f847b92 --- /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 0000000..605e707 --- /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 0000000..88bd9a3 --- /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 0000000..de33068 --- /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 0000000..873acec --- /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 0000000..38b891c --- /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 0000000..6e42560 --- /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 0000000..4405181 --- /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 0000000..f5964bc --- /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 0000000..5cd7938 --- /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 0000000..f0600a5 --- /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 0000000..fed3928 --- /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 0000000..17c0495 --- /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 0000000..d35d512 --- /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/85] 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 0000000..0bd9610 --- /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 0000000..535e262 --- /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 0000000..242b4d1 --- /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 0000000..d5d725c --- /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 0000000..7171ba3 --- /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 0000000..78ca53f --- /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 0000000..9f46f11 --- /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 0000000..9b89bd1 --- /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 0000000..a8569b0 --- /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 0000000..c5f85b0 --- /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 0000000..52908e1 --- /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 0000000..8509330 --- /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 0000000..128217f --- /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 0000000..e4c3cd4 --- /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 0000000..88cfd0c --- /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 0000000..58be7ff --- /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 0000000..a506c56 --- /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 0000000..a9f7718 --- /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 0000000..41e6346 --- /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 0000000..6dc067f --- /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 0000000..a2383a0 --- /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 0000000..80ae696 --- /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 0000000..cd51571 --- /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 0000000..abe267f --- /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 0000000..260f603 --- /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 0000000..629b423 --- /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 0000000..ade931b --- /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 0000000..3b4439b --- /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 0000000..fd8f03b --- /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 0000000..80f798f --- /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 0000000..10c64ef --- /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 0000000..2c649fc --- /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 0000000..d74989e --- /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 0000000..c49c8b6 --- /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 0000000..81e359c --- /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 0000000..6c5e04d --- /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 0000000..593565b --- /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 0000000..e830502 --- /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 0000000..87dc79d --- /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 0000000..6880d70 --- /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 0000000..797a50e --- /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 0000000..826aed1 --- /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 0000000..4d91334 --- /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 0000000..babf9b5 --- /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 0000000..17d0f88 --- /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 0000000..d2bce47 --- /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 0000000..c145771 --- /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 0000000..4cee0f0 --- /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 0000000..370aa2f --- /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 0000000..a2ab576 --- /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 0000000..6d04b0c --- /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 0000000..7ece174 --- /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 0000000..f841179 --- /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 0000000..125a328 --- /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 0000000..103c662 --- /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 0000000..c540065 --- /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 0000000..6eb5a3f --- /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 0000000..ae7881b --- /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 0000000..6c30105 --- /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 0000000..ddd13e6 --- /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 0000000..0e53c3b --- /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 0000000..8de2c17 --- /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 0000000..3f8db1d --- /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 0000000..971bc3d --- /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 0000000..bb3ceab --- /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 0000000..8388897 --- /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 0000000..785152d --- /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 0000000..756ab71 --- /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 0000000..ad5e4f7 --- /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 0000000..8d011d7 --- /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 0000000..eb230e8 --- /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 0000000..2b878ab --- /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 0000000..d506009 --- /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 0000000..8f9e6dd --- /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 0000000..d15f68a --- /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 0000000..dfa8b48 --- /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 0000000..867e41e --- /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 0000000..4773d4a --- /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 0000000..c9c3acf --- /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 0000000..8e0d475 --- /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 0000000..ade4cbe --- /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 0000000..78868af --- /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 0000000..61049ab --- /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 0000000..01dc5b0 --- /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 0000000..8aced78 --- /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 0000000..4d047e1 --- /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 0000000..9ef2680 --- /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 0000000..6a2ce72 --- /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 0000000..83c9442 --- /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 0000000..e7c06f1 --- /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 0000000..d5d359f --- /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 0000000..45ce017 --- /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 0000000..3e5ec86 --- /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 0000000..42ca6c7 --- /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 0000000..13e97ad --- /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 0000000..832d6eb --- /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 0000000..526febd --- /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 0000000..c859fab --- /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 0000000..414fd49 --- /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 0000000..26a3c51 --- /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 0000000..71b6876 --- /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 0000000..17d679d --- /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 0000000..e8760a7 --- /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 0000000..1ebdb28 --- /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 0000000..87197b2 --- /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 0000000..2a600e9 --- /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 0000000..a4e43e4 --- /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 0000000..516389f --- /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 0000000..854eace --- /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 0000000..c83e804 --- /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 0000000..6a16483 --- /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 0000000..206aa0f --- /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 0000000..0f866e0 --- /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 0000000..5cc279b --- /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 0000000..31e73ea --- /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 0000000..2a364cf --- /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 0000000..0d72ab1 --- /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 0000000..d693126 --- /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 0000000..79ccb49 --- /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 0000000..97ff67d --- /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 0000000..c1d94bd --- /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 0000000..286635e --- /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 0000000..683b1ed --- /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 0000000..6f1ecc8 --- /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 0000000..46059bb --- /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 0000000..e354a80 --- /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 0000000..15d1bab --- /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 0000000..079ecc0 --- /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 0000000..422445c --- /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 0000000..6b6974d --- /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 0000000..e9cd06f --- /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 0000000..5efeb5d --- /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 0000000..5192f7e --- /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 0000000..43f4c96 --- /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 0000000..21ac516 --- /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 0000000..ec77e4d --- /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 0000000..1536585 --- /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 0000000..96668ed --- /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 0000000..97bb42a --- /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 0000000..13e6333 --- /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 0000000..c8ca0a6 --- /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 0000000..06d57cf --- /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 0000000..36afb32 --- /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/85] 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 0000000..f8f23bb --- /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 0000000..bd1266a --- /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 0000000..9d7d2ad --- /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 0000000..d3d9fa8 --- /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 0000000..83b18d6 --- /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 0000000..a57e9f5 --- /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 0000000..014dfd8 --- /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 0000000..b70aec2 --- /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 0000000..16076b4 --- /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 0000000..50e602e --- /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 0000000..c14d3ec --- /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 0000000..e79f838 --- /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 0000000..a557038 --- /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 0000000..16a35f1 --- /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 0000000..1a6c9e5 --- /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 0000000..9c3c075 --- /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 0000000..13b5464 --- /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 0000000..ef315fe --- /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 0000000..af10949 --- /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 0000000..24b10e7 --- /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 0000000..d863182 --- /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 0000000..60e8911 --- /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 0000000..e1fe2b7 --- /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/85] 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 0000000..c46602e --- /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 0000000..85d7278 --- /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 0000000..7955e54 --- /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 0000000..40b7d96 --- /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 0000000..a55cbfa --- /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 0000000..a47cc8c --- /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 0000000..0b90f09 --- /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 0000000..5b03a28 --- /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 0000000..e4d7a76 --- /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 0000000..ab75a81 --- /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 0000000..b857318 --- /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 0000000..10160bd --- /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 0000000..d46a83a --- /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 0000000..7c24985 --- /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 0000000..3518074 --- /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 0000000..fd142e0 --- /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 0000000..df080f6 --- /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 0000000..e036119 --- /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 0000000..28dd94e --- /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 0000000..d12da64 --- /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 0000000..8658101 --- /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 0000000..cfb0bc5 --- /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 0000000..b48170a --- /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 0000000..e4b43ea --- /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/85] 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 0000000..b3bc630 --- /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 0000000..b53d7cf --- /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 0000000..900a3c4 --- /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 0000000..875b928 --- /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 0000000..1fa3f74 --- /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 0000000..18172fa --- /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 0000000..3dbff08 --- /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 0000000..5c4d363 --- /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 0000000..4dc54ee --- /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 0000000..15bb110 --- /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 0000000..47c0e1a --- /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 0000000..9acca53 --- /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 0000000..079253f --- /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 0000000..4bbe20f --- /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 0000000..83f6027 --- /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 0000000..94535d1 --- /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 0000000..74d14d7 --- /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 0000000..2073175 --- /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 0000000..8edfe39 --- /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 0000000..8462a7a --- /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 0000000..0f078af --- /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 0000000..60d96de --- /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 0000000..3b89ac4 --- /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 0000000..82adaee --- /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/85] 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 0000000..e9ddc64 --- /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 0000000..197eea6 --- /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 0000000..d409cc4 --- /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 0000000..e6b7be5 --- /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 0000000..6b999e3 --- /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 0000000..8ad3aae --- /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 0000000..784af39 --- /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 0000000..f8d54d7 --- /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 0000000..e45103b --- /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 0000000..7b74bef --- /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 0000000..cc0a4f5 --- /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 0000000..252811b --- /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 0000000..8ae46ae --- /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 0000000..da34914 --- /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 0000000..228e9e2 --- /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 0000000..7cc3086 --- /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 0000000..f52627a --- /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 0000000..4645948 --- /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 0000000..18ca4af --- /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/85] 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 0000000..2ab99ed --- /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 0000000..dbd3e08 --- /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 0000000..63de504 --- /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 0000000..d93c3da --- /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 0000000..371ac57 --- /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 0000000..b816360 --- /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 0000000..b88d0ba --- /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 0000000..84c3521 --- /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 0000000..d97f651 --- /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 0000000..2fe0ae5 --- /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 0000000..f3689c7 --- /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 0000000..72e65fd --- /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 0000000..01695a6 --- /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 0000000..920dbcf --- /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 0000000..bc9d0ab --- /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 0000000..877b7d3 --- /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 0000000..ddb5518 --- /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 0000000..7b7247b --- /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 0000000..63576dd --- /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 0000000..b30769c --- /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 0000000..fb38a2d --- /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 0000000..8967485 --- /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 0000000..8f39ad2 --- /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/85] 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 0000000..b34efe0 --- /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 0000000..c0459ab --- /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 0000000..c0580d0 --- /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 0000000..7dc1d9c --- /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 0000000..be4d7b1 --- /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 0000000..add6754 --- /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 0000000..33f01fa --- /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 0000000..4949006 --- /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 0000000..de9cdce --- /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 0000000..320f7e0 --- /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 0000000..23ddd58 --- /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 0000000..768ac95 --- /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 0000000..a9ebcfa --- /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 0000000..09e0e45 --- /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 0000000..df7b289 --- /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 0000000..69adec3 --- /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 0000000..ce6055d --- /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 0000000..205d4d1 --- /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 0000000..10400a1 --- /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 0000000..dcfc2f9 --- /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 0000000..2fafe4c --- /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 0000000..7a72b8e --- /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 0000000..3d89269 --- /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 0000000..d6a7742 --- /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 0000000..636da12 --- /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 0000000..0be91c2 --- /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 0000000..5ba2623 --- /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 0000000..dd669fa --- /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 0000000..ce5430b --- /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 0000000..a86a5e6 --- /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 0000000..5a8443f --- /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 0000000..a4c80a8 --- /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 0000000..b992fc1 --- /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 0000000..a9cb044 --- /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 0000000..185f655 --- /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 0000000..d89cdae --- /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 0000000..958e97a --- /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 0000000..513693f --- /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 0000000..4402991 --- /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 0000000..0ac5c9b --- /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 0000000..c0f975d --- /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 0000000..4ad7f5f --- /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 0000000..340cf3d --- /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 0000000..3487520 --- /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 0000000..6cca2aa --- /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 0000000..ac733d1 --- /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 0000000..ceb9ea8 --- /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 0000000..33e5403 --- /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 0000000..602343f --- /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 0000000..5e5be89 --- /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 0000000..2b2e09a --- /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 0000000..9992b20 --- /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 0000000..3b6f90a --- /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 0000000..c47f304 --- /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 0000000..0e90fc1 --- /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 0000000..64faf1e --- /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 0000000..3ab26a7 --- /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 0000000..56f1cc8 --- /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 0000000..ed4b904 --- /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 0000000..3ab0db7 --- /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 0000000..b43e506 --- /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 0000000..7489eda --- /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 0000000..999f39a --- /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 0000000..1893a7e --- /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 0000000..d2be927 --- /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 0000000..8e2ff94 --- /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 0000000..fc16de5 --- /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 0000000..98e3972 --- /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 0000000..a6330b2 --- /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 0000000..0565d09 --- /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 0000000..ebbe18d --- /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 0000000..bd6aa43 --- /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 0000000..282c715 --- /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 0000000..1b8f903 --- /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 0000000..c8f366b --- /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 0000000..d5e6ce9 --- /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 0000000..fef77d7 --- /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 0000000..742dd43 --- /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 0000000..49ee63e --- /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 0000000..b2a84d5 --- /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 0000000..0dd3c79 --- /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 0000000..4cd1f88 --- /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 0000000..0544b40 --- /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 0000000..a4d3881 --- /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 0000000..b40a4d5 --- /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 0000000..a685879 --- /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 0000000..7ecfc43 --- /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 0000000..9dadd1e --- /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 0000000..34ba0c2 --- /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 0000000..595490d --- /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 0000000..48e023c --- /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 0000000..4819d8d --- /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 0000000..ccb8d84 --- /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 0000000..5e9a66a --- /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 0000000..794492d --- /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 0000000..67945b2 --- /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 0000000..1fe62c2 --- /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 0000000..b31ef84 --- /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 0000000..5a5a9cc --- /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 0000000..b7f3544 --- /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 0000000..733cbcb --- /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 0000000..234d169 --- /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 0000000..d53986f --- /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 0000000..632910c --- /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 0000000..abb7020 --- /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 0000000..5589e93 --- /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 0000000..6b0ab0b --- /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 0000000..162cca6 --- /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 0000000..87ed251 --- /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 0000000..cb7e602 --- /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 0000000..76b88a3 --- /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 0000000..ea32370 --- /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 0000000..a8a5a54 --- /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 0000000..98d4b21 --- /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 0000000..391cbb0 --- /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 0000000..634c135 --- /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 0000000..2c895e9 --- /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 0000000..6cf8e21 --- /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 0000000..da4c11e --- /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 0000000..d9d872e --- /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 0000000..0b37936 --- /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 0000000..fe63a7a --- /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 0000000..62ed045 --- /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 0000000..86e6f09 --- /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 0000000..646370d --- /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 0000000..f530d6d --- /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 0000000..826faf6 --- /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 0000000..32ad81f --- /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 0000000..730fe16 --- /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 0000000..39541f6 --- /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 0000000..6a8a8fa --- /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 0000000..298c171 --- /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 0000000..596e635 --- /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 0000000..bb03c24 --- /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 0000000..c9b3ecb --- /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 0000000..7060197 --- /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 0000000..5994979 --- /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 0000000..592134b --- /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 0000000..8d83594 --- /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 0000000..5dfd0f9 --- /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 0000000..6b714ad --- /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 0000000..916686b --- /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 0000000..135bb3a --- /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 0000000..a9ca930 --- /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 0000000..4220d78 --- /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 0000000..7fe4ad2 --- /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 0000000..f88307b --- /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 0000000..901417f --- /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 0000000..048db0d --- /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 0000000..50281ff --- /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 0000000..5c0fddd --- /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 0000000..0c37e48 --- /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 0000000..b5191d0 --- /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 0000000..b553b06 --- /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 0000000..eadcecd --- /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 0000000..c6ca643 --- /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 0000000..5b25151 --- /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 0000000..e35c14e --- /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 0000000..50c0e65 --- /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 0000000..24a5f88 --- /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 0000000..06707c8 --- /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 0000000..79d6f55 --- /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 0000000..f18641e --- /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 0000000..f534ba9 --- /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 0000000..410b953 --- /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 0000000..f6af803 --- /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 0000000..5af5cc1 --- /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 0000000..ba2c539 --- /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 0000000..3bc6713 --- /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 0000000..22df27f --- /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 0000000..6f85b1e --- /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 0000000..c5bfd7d --- /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 0000000..69b2565 --- /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 0000000..ddf8288 --- /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 0000000..7d4b3a5 --- /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 0000000..6163600 --- /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 0000000..1a15786 --- /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 0000000..57b6112 --- /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 0000000..dc97a58 --- /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 0000000..680c725 --- /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 0000000..b604566 --- /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 0000000..19c6c55 --- /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 0000000..15137d3 --- /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 0000000..60a65ed --- /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 0000000..cf86cc5 --- /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 0000000..1eab3fc --- /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 0000000..c5b0eed --- /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 0000000..4de88c0 --- /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 0000000..bd7f4fb --- /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 0000000..6eaae7b --- /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/85] 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 0000000..8e9abb9 --- /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 0000000..437ed92 --- /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 0000000..19d6465 --- /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 0000000..769b19b --- /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 0000000..fad3d6e --- /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 0000000..928e197 --- /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 0000000..8fbf0ae --- /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 0000000..671cad0 --- /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 0000000..0ab9756 --- /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 0000000..5826909 --- /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 0000000..5116d1e --- /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 0000000..b1e3ce3 --- /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 0000000..5343366 --- /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 0000000..13b2e16 --- /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 0000000..4590087 --- /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 0000000..f821212 --- /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 0000000..5c6453b --- /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 0000000..ae47900 --- /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 0000000..3f5757d --- /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 0000000..d9aa12a --- /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 0000000..1a76949 --- /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 0000000..1f6de6d --- /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 0000000..3cfb5ea --- /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 0000000..dddc254 --- /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 0000000..5371855 --- /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 0000000..5d21776 --- /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 0000000..187de4b --- /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 0000000..2745420 --- /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 0000000..f72eebc --- /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 0000000..b8c2175 --- /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 0000000..d2d6ecb --- /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 0000000..2ea861f --- /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 0000000..3735a3c --- /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 0000000..c5b0a34 --- /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 0000000..d09b025 --- /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 0000000..8dcbd2a --- /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 0000000..0d809de --- /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 0000000..e2b7586 --- /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 0000000..0288c2c --- /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 0000000..e24e40d --- /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 0000000..6384c8e --- /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 0000000..73447b0 --- /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 0000000..46a5b1c --- /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 0000000..a5fae7f --- /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 0000000..e1cbdde --- /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 0000000..ef8d91a --- /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 0000000..4d603b8 --- /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 0000000..7ba8133 --- /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 0000000..8940ef1 --- /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 0000000..08a8751 --- /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 0000000..adc81b1 --- /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 0000000..956e09d --- /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 0000000..a91502f --- /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 0000000..c2af6a0 --- /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 0000000..58f30f5 --- /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 0000000..f3d98c2 --- /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 0000000..2525b3f --- /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 0000000..720d5ba --- /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 0000000..c9d9b95 --- /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 0000000..04d0595 --- /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 0000000..231ae9e --- /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 0000000..eb1ba1e --- /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 0000000..a36ab96 --- /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 0000000..653fa6a --- /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 0000000..acf1f8b --- /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 0000000..78259c4 --- /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 0000000..5ebce52 --- /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 0000000..e5e3af2 --- /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 0000000..f4e71cb --- /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 0000000..5d3cad2 --- /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 0000000..f8ca12e --- /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 0000000..2f600d7 --- /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 0000000..1e77579 --- /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 0000000..40a4c11 --- /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 0000000..29ffd39 --- /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 0000000..04733ef --- /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 0000000..c510745 --- /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 0000000..9c8647e --- /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 0000000..0458375 --- /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 0000000..e53269f --- /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 0000000..d89a319 --- /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 0000000..fee98a3 --- /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 0000000..4001588 --- /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 0000000..3d8e7f1 --- /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 0000000..5de97e9 --- /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 0000000..d7a3d5a --- /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 0000000..867f6de --- /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 0000000..d7188a8 --- /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 0000000..4485a13 --- /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 0000000..36233be --- /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 0000000..1e3afff --- /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 0000000..aa2ac8c --- /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 0000000..567f307 --- /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 0000000..5e983d7 --- /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 0000000..cb62725 --- /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 0000000..7e84c1b --- /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 0000000..12d73cd --- /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 0000000..e801890 --- /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 0000000..e3bf674 --- /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 0000000..a9607b3 --- /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 0000000..7e06d5f --- /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 0000000..3fc16cb --- /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 0000000..ccaa1f2 --- /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 0000000..3729c54 --- /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 0000000..b3580b3 --- /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 0000000..b166d80 --- /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 0000000..de03042 --- /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 0000000..a816af8 --- /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 0000000..1e3fdc0 --- /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 0000000..e6709fd --- /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 0000000..8dd7945 --- /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 0000000..57d7987 --- /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 0000000..8220904 --- /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 0000000..87fea80 --- /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 0000000..0fa5fc7 --- /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 0000000..4f3bf9f --- /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 0000000..81fb402 --- /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 0000000..0d985c8 --- /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 0000000..d95a49b --- /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 0000000..aec1753 --- /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 0000000..6ddd1c5 --- /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 0000000..0179a8b --- /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 0000000..54f6b03 --- /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 0000000..1e0df13 --- /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 0000000..2641c8a --- /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 0000000..2bdb4c7 --- /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 0000000..be9d46a --- /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 0000000..156a1a7 --- /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 0000000..3591163 --- /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 0000000..a7798ed --- /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 0000000..cb98032 --- /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 0000000..72b1c0c --- /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 0000000..c1a8b57 --- /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 0000000..01cee6d --- /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 0000000..fe4e55b --- /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 0000000..eb10b2d --- /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 0000000..7daf65b --- /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 0000000..c60ae2a --- /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 0000000..b2980b5 --- /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 0000000..58fe265 --- /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 0000000..ec3fd64 --- /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 0000000..45c9be8 --- /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 0000000..a86ac07 --- /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 0000000..e3d4994 --- /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 0000000..48b0336 --- /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 0000000..59be1d7 --- /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 0000000..47940b7 --- /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 0000000..d358f33 --- /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 0000000..6513f67 --- /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 0000000..2075957 --- /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 0000000..4ce15eb --- /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 0000000..f7e2fec --- /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 0000000..a07ea56 --- /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 0000000..f91f2aa --- /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 0000000..7eddc7c --- /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 0000000..b93ea5b --- /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 0000000..a4ee27b --- /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 0000000..b4a7adc --- /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 0000000..e62997c --- /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 0000000..253c268 --- /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 0000000..485d1dc --- /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 0000000..5fca2f5 --- /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 0000000..f4ca7c1 --- /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 0000000..3ade114 --- /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 0000000..e197311 --- /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 0000000..572bb78 --- /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 0000000..b4e10b9 --- /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 0000000..0b68631 --- /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 0000000..b649b9d --- /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 0000000..40101c8 --- /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 0000000..c437a87 --- /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 0000000..cb0d8d8 --- /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 0000000..6e21a6b --- /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 0000000..28654d5 --- /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 0000000..c0ee0b4 --- /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 0000000..29a337f --- /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 0000000..d24aafd --- /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 0000000..dbe540a --- /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 0000000..c537b0a --- /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 0000000..cab0775 --- /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 0000000..11b0d07 --- /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 0000000..aa64957 --- /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 0000000..ff7801f --- /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 0000000..0181361 --- /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 0000000..921f1c2 --- /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 0000000..4a1aeac --- /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 0000000..9a268cb --- /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 0000000..48c8ec7 --- /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 0000000..fe44fa8 --- /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 0000000..e33b1c4 --- /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 0000000..f031273 --- /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 0000000..ebcb9f8 --- /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 0000000..7246f35 --- /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 0000000..c381426 --- /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 0000000..422fff1 --- /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 0000000..e30bc5a --- /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 0000000..84b5587 --- /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 0000000..1cda42d --- /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 0000000..bab8537 --- /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 0000000..476af90 --- /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 0000000..efedc5e --- /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 0000000..e1f0a00 --- /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 0000000..dc0885f --- /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 0000000..9330c78 --- /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 0000000..fb146e1 --- /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 0000000..9021a3f --- /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 0000000..2e04ed7 --- /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 0000000..9fc9baa --- /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 0000000..dedca71 --- /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 0000000..82595b1 --- /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 0000000..8835b4e --- /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 0000000..a631100 --- /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 0000000..de83518 --- /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 0000000..e559f43 --- /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 0000000..d804649 --- /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 0000000..297b0da --- /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 0000000..0975f0b --- /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 0000000..40d1a8e --- /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 0000000..8451d48 --- /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 0000000..d88c028 --- /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 0000000..8b15bb4 --- /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 0000000..5b79a0e --- /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 0000000..3e0fc36 --- /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 0000000..0f7a030 --- /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 0000000..876549b --- /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 0000000..b16fe11 --- /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 0000000..7c451db --- /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 0000000..8270bb3 --- /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 0000000..840ca13 --- /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 0000000..3874053 --- /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 0000000..9291b12 --- /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 0000000..b1af286 --- /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 0000000..ab85698 --- /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 0000000..9b55195 --- /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 0000000..859d51d --- /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 0000000..51c1068 --- /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 0000000..1d1cf54 --- /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 0000000..df2cab9 --- /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 0000000..149adf3 --- /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 0000000..4f55f9d --- /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 0000000..a12c206 --- /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 0000000..af6756c --- /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 0000000..56ff45d --- /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 0000000..5a0e9df --- /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 0000000..f309f5d --- /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 0000000..8cda11d --- /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 0000000..69f3f09 --- /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 0000000..1688085 --- /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 0000000..2f40c52 --- /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 0000000..4f64215 --- /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 0000000..468299b --- /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 0000000..387ab01 --- /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 0000000..1965aec --- /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 0000000..615ce29 --- /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 0000000..28b4f75 --- /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 0000000..ecde945 --- /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 0000000..d432dc9 --- /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 0000000..0630f32 --- /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 0000000..692cac5 --- /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 0000000..0d145b7 --- /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 0000000..ce5a5cd --- /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 0000000..07ca719 --- /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 0000000..0dbc687 --- /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 0000000..6600186 --- /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 0000000..20c649c --- /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 0000000..6d25de2 --- /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 0000000..c6ec68a --- /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 0000000..020dea5 --- /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 0000000..88f8b7c --- /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 0000000..e995213 --- /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 0000000..266d69e --- /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 0000000..b11dfa4 --- /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 0000000..6aaf676 --- /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 0000000..8577560 --- /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 0000000..44cd726 --- /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 0000000..b01b575 --- /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 0000000..f283f8c --- /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 0000000..5dd4bbf --- /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 0000000..bb4ebeb --- /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 0000000..aed0247 --- /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 0000000..c2becf7 --- /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 0000000..970f6ad --- /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 0000000..8e71bcf --- /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 0000000..a13ca95 --- /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 0000000..0741d2c --- /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 0000000..2a3e56c --- /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 0000000..5cf00e0 --- /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 0000000..69f4fc9 --- /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 0000000..48ca298 --- /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 0000000..699eb76 --- /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 0000000..b391ac1 --- /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 0000000..4efe884 --- /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 0000000..892b211 --- /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 0000000..e0c3a96 --- /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 0000000..520c7a0 --- /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 0000000..209a92d --- /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 0000000..91c3907 --- /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 0000000..b8d8788 --- /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 0000000..6b76d08 --- /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 0000000..af659c7 --- /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 0000000..a4a5f69 --- /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 0000000..92359e5 --- /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 0000000..12fef88 --- /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 0000000..55d0f14 --- /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 0000000..684fe12 --- /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 0000000..daa0e9a --- /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 0000000..7605b8c --- /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 0000000..51b233b --- /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 0000000..0ccfe3d --- /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 0000000..f44887d --- /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 0000000..ec883ad --- /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 0000000..1f31be4 --- /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 0000000..2e2a180 --- /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 0000000..99781a2 --- /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 0000000..d059c52 --- /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 0000000..b548d8f --- /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 0000000..cb4d268 --- /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 0000000..b099755 --- /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 0000000..005e2ef --- /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 0000000..1bb1b37 --- /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 0000000..6ca0cd8 --- /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 0000000..1a34914 --- /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 0000000..8cedefc --- /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 0000000..a02eb0a --- /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 0000000..b60afd8 --- /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 0000000..e38dff0 --- /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 0000000..f753d14 --- /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 0000000..2d01229 --- /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 0000000..f9f3198 --- /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 0000000..dde2f8e --- /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 0000000..278a45d --- /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 0000000..2afb0d9 --- /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 0000000..b0f92a3 --- /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 0000000..01bd240 --- /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 0000000..80d174c --- /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 0000000..013b7b0 --- /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 0000000..7cd1399 --- /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 0000000..e599ecb --- /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 0000000..cd4f3fd --- /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 0000000..4d56686 --- /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 0000000..b85d9c4 --- /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 0000000..a6b7134 --- /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 0000000..95d2908 --- /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 0000000..7a6032b --- /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 0000000..4e405be --- /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 0000000..7ffb93b --- /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 0000000..fbd72df --- /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 0000000..bb46035 --- /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 0000000..d4ced3f --- /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 0000000..e168e53 --- /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 0000000..30578de --- /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 0000000..5e170ca --- /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 0000000..4773930 --- /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 0000000..bbb3c36 --- /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 0000000..5cef526 --- /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 0000000..6e66a77 --- /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 0000000..171f246 --- /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 0000000..8407e74 --- /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 0000000..fcf7041 --- /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 0000000..c26cf03 --- /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 0000000..1fa41aa --- /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 0000000..a25c3bb --- /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 0000000..398da40 --- /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 0000000..0002a9e --- /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 0000000..788c3b9 --- /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 0000000..214eff3 --- /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 0000000..590ca56 --- /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 0000000..8ca121d --- /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 0000000..a9ba764 --- /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 0000000..4c537fd --- /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 0000000..c5dcb7c --- /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 0000000..d5d4480 --- /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 0000000..d10b135 --- /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 0000000..a76bb82 --- /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 0000000..8009d5c --- /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 0000000..d13fe92 --- /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 0000000..7902645 --- /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 0000000..de83c69 --- /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 0000000..b6f25a2 --- /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 0000000..5be3047 --- /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 0000000..1b9dad5 --- /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 0000000..4bc6848 --- /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 0000000..9679333 --- /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 0000000..98d9e2a --- /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 0000000..d6c3609 --- /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 0000000..6c2f278 --- /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 0000000..82ab51d --- /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 0000000..0c9c555 --- /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 0000000..f87322f --- /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 0000000..f21fa54 --- /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 0000000..33e6d74 --- /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 0000000..5bae83b --- /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 0000000..c3f5cdf --- /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 0000000..d346b80 --- /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 0000000..3929e5c --- /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 0000000..8f6ab94 --- /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 0000000..f80eb61 --- /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 0000000..1511c75 --- /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 0000000..e19886d --- /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 0000000..7af1042 --- /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 0000000..50d9fbf --- /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 0000000..73ef4bf --- /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 0000000..cc9761f --- /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 0000000..e016a93 --- /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 0000000..00dad7d --- /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 0000000..aed8860 --- /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 0000000..b15f1c2 --- /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 0000000..f624f6d --- /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 0000000..e03d0d0 --- /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 0000000..53a716d --- /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 0000000..a957473 --- /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 0000000..32dbb42 --- /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 0000000..8d99956 --- /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 0000000..6ff5b47 --- /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 0000000..f564c9e --- /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 0000000..3e03910 --- /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 0000000..c42f547 --- /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 0000000..bd401c1 --- /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 0000000..f885cd7 --- /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 0000000..7680058 --- /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 0000000..b1674bb --- /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 0000000..4c07949 --- /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 0000000..118d990 --- /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 0000000..718239b --- /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 0000000..f24b693 --- /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 0000000..c389b0b --- /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 0000000..7a6b831 --- /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 0000000..496632d --- /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 0000000..a6c3aff --- /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 0000000..6e554d2 --- /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 0000000..3cf79ce --- /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 0000000..849087e --- /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 0000000..1b6c6d4 --- /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 0000000..23ceb4a --- /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 0000000..204c830 --- /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 0000000..244df4c --- /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 0000000..43634e4 --- /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 0000000..be7bb91 --- /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 0000000..db28829 --- /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 0000000..fec5857 --- /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 0000000..06ba3da --- /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 0000000..1c22e83 --- /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 0000000..5356c2b --- /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 0000000..50527c0 --- /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 0000000..5ad4aff --- /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 0000000..bdb65aa --- /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 0000000..e248714 --- /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 0000000..845bc72 --- /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 0000000..8ac58e4 --- /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 0000000..f22f4f2 --- /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 0000000..e0a70d8 --- /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 0000000..add0a6a --- /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 0000000..3d90442 --- /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 0000000..5320e5e --- /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 0000000..b918aff --- /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 0000000..9771096 --- /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 0000000..3b4cc2f --- /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 0000000..be892b1 --- /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 0000000..83990ab --- /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 0000000..7d5ec13 --- /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 0000000..02458c6 --- /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 0000000..c15583e --- /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 0000000..170c404 --- /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 0000000..ece2fb2 --- /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 0000000..bcd3806 --- /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 0000000..e80738a --- /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 0000000..28fb8ad --- /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 0000000..0fc5084 --- /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 0000000..29b97c7 --- /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 0000000..39e85cf --- /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 0000000..cbdc698 --- /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 0000000..bcd8d18 --- /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 0000000..82a11c8 --- /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 0000000..877aa6b --- /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 0000000..cc9522e --- /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 0000000..298627e --- /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 0000000..492c043 --- /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 0000000..986d050 --- /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 0000000..08d5bb7 --- /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 0000000..ce8d547 --- /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 0000000..69202c5 --- /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 0000000..8f6d3b1 --- /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 0000000..df8e7ad --- /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 0000000..db2de06 --- /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 0000000..a62b977 --- /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 0000000..85bfa4d --- /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 0000000..a630d2e --- /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 0000000..09f8285 --- /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 0000000..147df7f --- /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 0000000..b2ba3a7 --- /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 0000000..f083c62 --- /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 0000000..52116dd --- /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 0000000..100cb34 --- /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 0000000..08c8fc7 --- /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 0000000..0222908 --- /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 0000000..5626971 --- /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 0000000..b038ec8 --- /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 0000000..1acd12f --- /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 0000000..41d5e15 --- /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 0000000..5e26b89 --- /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 0000000..a13d57f --- /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 0000000..c78825b --- /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 0000000..ec8518c --- /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 0000000..2edc358 --- /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 0000000..ca66f7f --- /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 0000000..18742d8 --- /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 0000000..15f95f2 --- /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 0000000..8352ec1 --- /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/85] 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 0000000..44e21ea --- /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 0000000..6a98326 --- /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 0000000..11c0e10 --- /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 0000000..91d3029 --- /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 0000000..fec15db --- /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 0000000..ab87b4b --- /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 0000000..1723034 --- /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 0000000..f1c7883 --- /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 0000000..6bcf8d0 --- /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 0000000..af7ae76 --- /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 0000000..8696f7d --- /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 0000000..db3c839 --- /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 0000000..f2ae3f8 --- /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 0000000..7fe0d1b --- /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 0000000..473fa96 --- /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 0000000..07835a6 --- /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 0000000..090be80 --- /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 0000000..f3ec37a --- /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 0000000..80e014e --- /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 0000000..92a7635 --- /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 0000000..31b6960 --- /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 0000000..605791e --- /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 0000000..db422d2 --- /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 0000000..c7c474a --- /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 0000000..ddd29c9 --- /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 0000000..0d9694a --- /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 0000000..25cda2f --- /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 0000000..076ec26 --- /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 0000000..5b0f6f0 --- /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 0000000..ed41f5e --- /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/85] 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 0000000..1a827a8 --- /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 0000000..07d5c35 --- /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 0000000..621ddab --- /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 0000000..3c17d95 --- /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 0000000..3970025 --- /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 0000000..1faf11f --- /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 0000000..6df823e --- /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 0000000..81b8dca --- /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 0000000..716037f --- /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 0000000..10277e1 --- /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 0000000..b5f655c --- /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 0000000..47644c7 --- /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 0000000..cdf0ce7 --- /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 0000000..ce39316 --- /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 0000000..2aaea22 --- /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 0000000..d1f3df9 --- /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 0000000..7bcc13f --- /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 0000000..2e32b2d --- /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 0000000..e65b714 --- /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 0000000..7e528c8 --- /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 0000000..8558ad9 --- /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 0000000..17753e6 --- /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 0000000..5a335d1 --- /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 0000000..fe7ad71 --- /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 0000000..c2d7ec0 --- /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 0000000..26b8c96 --- /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 0000000..63e9871 --- /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 0000000..bcd738c --- /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 0000000..7bf2623 --- /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 0000000..2965fb9 --- /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 0000000..e6391de --- /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 0000000..b7705a1 --- /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 0000000..6b48aad --- /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 0000000..716f3ae --- /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 0000000..684b490 --- /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 0000000..2c56acb --- /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 0000000..5f2e702 --- /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 0000000..09ab7eb --- /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 0000000..3af8936 --- /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 0000000..b79065b --- /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 0000000..cc30162 --- /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 0000000..1d2f75e --- /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 0000000..73cd7bb --- /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 0000000..9c8b3ab --- /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 0000000..1d91ea0 --- /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 0000000..483b68f --- /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 0000000..668eeb7 --- /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 0000000..2a54e62 --- /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 0000000..84206b2 --- /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 0000000..e8359db --- /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 0000000..730c466 --- /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 0000000..3fb359e --- /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 0000000..2853968 --- /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 0000000..3bcf628 --- /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 0000000..71dcaa6 --- /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 0000000..1fccb8e --- /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 0000000..4aa4bcc --- /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 0000000..fab9bdd --- /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 0000000..0a97907 --- /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 0000000..c35e0f7 --- /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 0000000..0f31baf --- /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 0000000..c83cc6d --- /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 0000000..e31f720 --- /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 0000000..9e1266e --- /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 0000000..322ef0e --- /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 0000000..63f5ffd --- /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 0000000..3cabf2f --- /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 0000000..df32f58 --- /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 0000000..e16aa66 --- /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 0000000..fb8df3d --- /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 0000000..2e6e019 --- /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 0000000..cca2bad --- /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 0000000..cfa6070 --- /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 0000000..83796e4 --- /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 0000000..7f3d299 --- /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 0000000..9ffe240 --- /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 0000000..7b85778 --- /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 0000000..a75911a --- /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 0000000..2c76fa9 --- /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 0000000..95c0727 --- /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 0000000..87f3155 --- /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 0000000..8643864 --- /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 0000000..4ea193f --- /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 0000000..f0748b2 --- /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 0000000..7c01e66 --- /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 0000000..7723347 --- /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 0000000..e70c344 --- /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 0000000..98fe576 --- /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 0000000..9181c63 --- /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 0000000..4669ff3 --- /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 0000000..d83bcca --- /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 0000000..0cbe926 --- /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 0000000..768a459 --- /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 0000000..7ca8aff --- /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 0000000..db566b7 --- /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 0000000..e544bed --- /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 0000000..83d5f26 --- /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 0000000..5ed7021 --- /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 0000000..7f91ee7 --- /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 0000000..2102fbb --- /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 0000000..d43ef22 --- /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 0000000..046eb53 --- /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 0000000..866ee13 --- /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 0000000..f997b01 --- /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 0000000..dace812 --- /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 0000000..8fba94e --- /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 0000000..8714701 --- /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 0000000..6a1b384 --- /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 0000000..d721d92 --- /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 0000000..9280f1a --- /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 0000000..dfc9f37 --- /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 0000000..743de31 --- /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 0000000..29e89a8 --- /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 0000000..727571d --- /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 0000000..5b0625f --- /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 0000000..c35c70f --- /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 0000000..0dea408 --- /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 0000000..88217c3 --- /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 0000000..8f67b0c --- /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 0000000..0c462ff --- /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 0000000..9513f05 --- /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 0000000..0cb30d9 --- /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 0000000..be17e7f --- /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 0000000..4f17823 --- /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 0000000..9bb1949 --- /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 0000000..4a55156 --- /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 0000000..3f3d892 --- /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 0000000..b40fae5 --- /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 0000000..68ac0b7 --- /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 0000000..fb32f1c --- /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 0000000..dce2d96 --- /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 0000000..7213ff0 --- /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 0000000..14da09f --- /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 0000000..9b1a109 --- /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 0000000..5ff0551 --- /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 0000000..085edf9 --- /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 0000000..612d091 --- /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 0000000..8406556 --- /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 0000000..04e6c66 --- /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 0000000..aecfe87 --- /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 0000000..f82480b --- /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 0000000..155a53d --- /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 0000000..83e927c --- /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 0000000..381ae64 --- /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 0000000..d0c91cd --- /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 0000000..cb212c6 --- /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 0000000..f3ec14f --- /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 0000000..6b7a97c --- /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 0000000..0b9d532 --- /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 0000000..8eecdb0 --- /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 0000000..3efa596 --- /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 0000000..79f64db --- /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 0000000..7ee3451 --- /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 0000000..0ca4ea7 --- /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 0000000..b7f94cc --- /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 0000000..d5cc5e0 --- /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 0000000..ab54b82 --- /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 0000000..7e01f92 --- /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 0000000..1965455 --- /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 0000000..46b441d --- /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 0000000..eea799f --- /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 0000000..338f95e --- /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 0000000..d2c8daa --- /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 0000000..2c34eee --- /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 0000000..33be222 --- /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 0000000..1509950 --- /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 0000000..a6b4b75 --- /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 0000000..6345e67 --- /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 0000000..8805ccf --- /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 0000000..285f367 --- /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 0000000..9416280 --- /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 0000000..881b735 --- /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 0000000..6f2f6e9 --- /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 0000000..f7e313c --- /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 0000000..8e33b55 --- /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 0000000..9115fb0 --- /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 0000000..e5b9a0c --- /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 0000000..21cb78f --- /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 0000000..5a402ba --- /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 0000000..2d2c70b --- /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 0000000..7cc3338 --- /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 0000000..90e0f2a --- /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 0000000..af65d31 --- /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 0000000..b3b349c --- /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 0000000..fa283f8 --- /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 0000000..eb3ae7e --- /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 0000000..833cb78 --- /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 0000000..e673a61 --- /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 0000000..d1bdbd2 --- /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 0000000..f04b4ae --- /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 0000000..0893b69 --- /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 0000000..e9d7cd7 --- /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 0000000..07ba939 --- /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 0000000..00b409d --- /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 0000000..307df41 --- /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 0000000..1273902 --- /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 0000000..b79beaf --- /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 0000000..a3fca31 --- /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 0000000..7df511f --- /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 0000000..b71c385 --- /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 0000000..556497d --- /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/85] 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 f04b4ae..1ca4908 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/85] 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 0000000..cb305d4 --- /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 0000000..1d6f017 --- /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 0000000..d199506 --- /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 0000000..a25b7dc --- /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 0000000..4315582 --- /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 0000000..5860d0f --- /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 0000000..6b32549 --- /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 0000000..7feba2b --- /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 0000000..1e0aa94 --- /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 0000000..8066554 --- /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 0000000..2a4e561 --- /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 0000000..c584844 --- /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 0000000..8f770fb --- /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 0000000..887473e --- /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 0000000..9c0ad3e --- /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 0000000..3503633 --- /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 0000000..ed54d5e --- /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 0000000..29837e4 --- /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 0000000..aaad9e7 --- /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 0000000..47e9255 --- /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 0000000..e333023 --- /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 0000000..746617e --- /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 0000000..af8f11f --- /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/85] 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 af8f11f..fd94a6b 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 0000000..df57788 --- /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 0000000..fb6a53d --- /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 0000000..a2cafc3 --- /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 0000000..bbc8cb4 --- /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 0000000..283cfc5 --- /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 0000000..e8bf6d5 --- /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 0000000..7ff3b61 --- /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 0000000..cf72683 --- /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 0000000..7ecf06a --- /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 0000000..3db71ec --- /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 0000000..b598e5e --- /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 0000000..c2048e6 --- /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/85] 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 0000000..b5cc9d4 --- /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 0000000..9453c2f --- /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 0000000..6596f7a --- /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 0000000..8a6c146 --- /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 0000000..9ea3c45 --- /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 0000000..7603b2b --- /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 0000000..373f0b2 --- /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 0000000..aeae56b --- /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 0000000..2915bf3 --- /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 0000000..dc59240 --- /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 0000000..236d906 --- /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 0000000..8ea9cea --- /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 0000000..1631437 --- /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 0000000..1881371 --- /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 0000000..fb0a2b4 --- /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 0000000..1136bdf --- /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 0000000..5b30231 --- /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 0000000..87e8264 --- /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 0000000..cd22b2a --- /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 0000000..bcebc66 --- /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 0000000..45b23c4 --- /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 0000000..2520063 --- /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 0000000..610c6d7 --- /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 0000000..d78c306 --- /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 0000000..9593270 --- /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 0000000..9b6ffad --- /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 0000000..af97cc3 --- /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 0000000..2198717 --- /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 0000000..9dbfa95 --- /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 0000000..3b8dd15 --- /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 0000000..51e71f5 --- /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 0000000..36da2ba --- /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 0000000..ae35a07 --- /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 0000000..ce4b355 --- /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 0000000..4a4c298 --- /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 0000000..a78d901 --- /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 0000000..b9c2318 --- /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 0000000..defa244 --- /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 0000000..0d64a54 --- /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 0000000..fa56c02 --- /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 0000000..d7fef37 --- /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 0000000..c7de2aa --- /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 0000000..859bb07 --- /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 0000000..f472ba2 --- /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 0000000..bb3ab74 --- /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 0000000..444b9f4 --- /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 0000000..6d76567 --- /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 0000000..60ce42e --- /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 0000000..5eca2d8 --- /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 0000000..b2a7a56 --- /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 0000000..759dd31 --- /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 0000000..a3be5b2 --- /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 0000000..da63c91 --- /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 0000000..d2bf4c4 --- /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 0000000..d8c32ba --- /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 0000000..5fcd636 --- /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 0000000..05f22ab --- /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 0000000..215ada9 --- /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 0000000..c4563f0 --- /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 0000000..dbb6e79 --- /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 0000000..a7ce1de --- /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 0000000..1f49b3c --- /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 0000000..93a59aa --- /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 0000000..cd96e87 --- /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 0000000..121af59 --- /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 0000000..3440d12 --- /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 0000000..2b98cef --- /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 0000000..17a45ad --- /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 0000000..c812d39 --- /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 0000000..9e25193 --- /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 0000000..8dcae0d --- /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 0000000..e3c67c5 --- /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 0000000..5926479 --- /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 0000000..b64a1e0 --- /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 0000000..63cf3a3 --- /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 0000000..6f57225 --- /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 0000000..a1e609e --- /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 0000000..43d998e --- /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 0000000..3037584 --- /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 0000000..520ac24 --- /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 0000000..a9f8753 --- /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 0000000..0f3062e --- /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 0000000..0f8243a --- /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 0000000..71ebce4 --- /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 0000000..5266fae --- /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 0000000..761c22a --- /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 0000000..4d230b2 --- /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 0000000..988b4ee --- /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 0000000..eed1f9c --- /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 0000000..30c9e3f --- /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 0000000..8c86d01 --- /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 0000000..8fec1a5 --- /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 0000000..82905fa --- /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 0000000..6fc5ac7 --- /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 0000000..eb34336 --- /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 0000000..9ecb214 --- /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 0000000..8a460c4 --- /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 0000000..b1bc676 --- /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 0000000..b5d4bed --- /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 0000000..a7a93f1 --- /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 0000000..59b7c88 --- /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 0000000..a6d0079 --- /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 0000000..d0650e0 --- /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 0000000..cf94a67 --- /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 0000000..5cc0b51 --- /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 0000000..48662c6 --- /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 0000000..b0aa89f --- /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 0000000..ca30f52 --- /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 0000000..4aa0abc --- /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 0000000..ca18cd9 --- /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 0000000..2a50ea0 --- /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 0000000..701e603 --- /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 0000000..cc9f1f2 --- /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 0000000..8d910b2 --- /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 0000000..9044cbe --- /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 0000000..eb349eb --- /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 0000000..bffdaef --- /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 0000000..3383f7b --- /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 0000000..c349dc3 --- /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 0000000..93eeb96 --- /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 0000000..5efd04e --- /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 0000000..d4a97fb --- /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 0000000..e647067 --- /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 0000000..98a0fa1 --- /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 0000000..2c7f07c --- /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 0000000..b9039ba --- /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 0000000..d168480 --- /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 0000000..d109353 --- /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 0000000..dac87fa --- /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 0000000..f423fd8 --- /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 0000000..e77c47e --- /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 0000000..97e75c0 --- /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 0000000..0657838 --- /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 0000000..355584b --- /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 0000000..23fd630 --- /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 0000000..6168091 --- /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 0000000..43fb9a5 --- /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 0000000..9fd28dd --- /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 0000000..a87bc30 --- /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 0000000..d2f3a52 --- /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 0000000..49cae2d --- /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 0000000..7431450 --- /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 0000000..c53d7e1 --- /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 0000000..bc857b8 --- /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 0000000..9723511 --- /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 0000000..5c2b981 --- /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 0000000..4f377aa --- /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 0000000..cd46b0d --- /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 0000000..cda7ab3 --- /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 0000000..60f6336 --- /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 0000000..e67a0ae --- /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 0000000..e0ae6e2 --- /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 0000000..652c419 --- /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 0000000..3d43ca2 --- /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 0000000..103bd50 --- /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 0000000..358d8ae --- /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 0000000..b37ce6f --- /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 0000000..c724b66 --- /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 0000000..602afdb --- /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 0000000..6fd7a3d --- /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 0000000..238477d --- /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 0000000..70b789e --- /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 0000000..a8f8095 --- /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 0000000..cfd1fe9 --- /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 0000000..d010ee9 --- /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 0000000..4f362ae --- /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 0000000..2598da8 --- /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 0000000..d1b3add --- /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 0000000..93b4e65 --- /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 0000000..7637e2f --- /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 0000000..28fec13 --- /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 0000000..f535a7b --- /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 0000000..6e6060d --- /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 0000000..223077b --- /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 0000000..718b0d7 --- /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 0000000..97d96d8 --- /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 0000000..92f8ce3 --- /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 0000000..1ad9c61 --- /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 0000000..543eb45 --- /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 0000000..c6fc7d6 --- /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 0000000..c737911 --- /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 0000000..1d4268d --- /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 0000000..14f43e1 --- /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 0000000..ec95038 --- /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 0000000..2ca9ebd --- /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 0000000..68e6041 --- /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 0000000..35d9112 --- /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 0000000..6bd95a9 --- /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 0000000..1bc8d3b --- /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 0000000..f27cdbe --- /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 0000000..4927d91 --- /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 0000000..ba1fb0e --- /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 0000000..7dc7fe0 --- /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 0000000..a0ea9c1 --- /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 0000000..23a09b4 --- /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 0000000..32219b3 --- /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 0000000..a354947 --- /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 0000000..9248ecd --- /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/85] 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 535e262..ff45892 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 8e9abb9..996c931 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 437ed92..475df61 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 19d6465..515c4e5 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 769b19b..5e4ac67 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 fad3d6e..387b0a8 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 928e197..d81abd0 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 8fbf0ae..4daa72d 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 671cad0..37c559c 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 0ab9756..e875b62 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 5826909..96e0514 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 5116d1e..5422ae7 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 b1e3ce3..daebfc7 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 5343366..28b559f 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 f821212..77139c3 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 1a76949..3f16a25 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 1f6de6d..4411171 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 3cfb5ea..72e0e12 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 dddc254..6d99b7b 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 5371855..880c5ab 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 5d21776..85e1203 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 187de4b..7fe07a9 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 2745420..9eba0fe 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 f72eebc..0d45f6e 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 b8c2175..5596935 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 d2d6ecb..914bd41 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 2ea861f..adccfd0 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 3735a3c..3d7f8b7 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 c5b0a34..7feab02 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 d09b025..96ff99a 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 8dcbd2a..a2a8cab 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 0d809de..8203af2 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 e2b7586..f354e7e 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 0288c2c..e768f6e 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 e24e40d..32fd49e 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 6384c8e..e901d86 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 73447b0..460e760 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 46a5b1c..896b7c9 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 a5fae7f..a02e991 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 e1cbdde..306c18a 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 ef8d91a..92aa7b3 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 4d603b8..9b1bed8 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 7ba8133..f59443b 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 8940ef1..3e8e4b2 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 08a8751..6d18583 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 adc81b1..d989679 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 956e09d..7240c6f 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 a91502f..ebd56a7 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 c2af6a0..4bccf89 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 58f30f5..e7de5b0 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 f3d98c2..47b16bb 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 c9d9b95..bdda012 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 e5e3af2..4844e87 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 f4e71cb..05ec7ab 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 5d3cad2..3185bb1 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 f8ca12e..d6759b8 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 2f600d7..4faf12a 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 1e77579..321782a 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 40a4c11..6c81dfc 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 29ffd39..df5fa7c 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 04733ef..17cb9bf 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 c510745..4b3d90e 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 9c8647e..76b5e85 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 0458375..cd30ecf 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 e53269f..6c92945 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 d89a319..1d9fa47 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 fee98a3..912cbc0 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 4001588..6111b65 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 3d8e7f1..b9653d0 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 5de97e9..cb5825f 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 d7a3d5a..5bf5d1b 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 4485a13..162036a 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 36233be..25be1b6 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 1e3afff..fd17a63 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 aa2ac8c..a872119 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 567f307..a7d7f3b 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 5e983d7..609e2ef 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 cb62725..3d5d934 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 7e84c1b..e46da42 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 12d73cd..8d0a6b0 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 e801890..35c269f 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 e3bf674..ac1a2a9 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 a9607b3..501d19d 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 7e06d5f..c06b182 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 3fc16cb..4aaec6f 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 ccaa1f2..718b9d4 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 3729c54..f2204e7 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 b3580b3..fae7b39 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 b166d80..a6999f7 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 de03042..1b3a3dc 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 a816af8..50edf80 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 1e3fdc0..f0bc503 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 e6709fd..6eead36 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 8dd7945..7939536 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 57d7987..7a7640c 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 8220904..77690f0 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 87fea80..db0d1bd 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 0fa5fc7..0368276 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 4f3bf9f..a282520 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 81fb402..c69a6d7 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 0d985c8..42c16d8 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 d95a49b..201f2c7 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 aec1753..3b3e7c1 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 6ddd1c5..2d401bc 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 0179a8b..349682f 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 54f6b03..3c503ce 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 1e0df13..161f61a 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 2641c8a..7fe77c5 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 2bdb4c7..cd95bd1 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 be9d46a..ffade3d 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 156a1a7..c9b55e7 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 3591163..f155d32 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 a7798ed..ae6d79a 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 cb98032..bcb20ed 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 72b1c0c..51cc4dc 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 c1a8b57..b4e77f4 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 01cee6d..7a2605a 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 fe4e55b..6f511dc 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 eb10b2d..4e9a356 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 7daf65b..5a6196d 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 c60ae2a..1224b34 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 b2980b5..c17fd74 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 58fe265..954077a 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 ec3fd64..9f4011a 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 45c9be8..d38b909 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 a86ac07..e7a133c 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 e3d4994..12d02b6 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 48b0336..d7b3ccd 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 59be1d7..11b86b3 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 47940b7..017d36a 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 d358f33..9d795cc 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 6513f67..7982787 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 2075957..f32bd0d 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 4ce15eb..543448e 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 f7e2fec..3b9edaa 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 a07ea56..76765cc 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 f91f2aa..e040c97 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 7eddc7c..89c5db8 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 b93ea5b..d3f637a 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 a4ee27b..4b02570 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 b4a7adc..bded879 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 e62997c..21b6c83 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 253c268..51f0908 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 485d1dc..a883f93 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 5fca2f5..7e71a01 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 f4ca7c1..61483e3 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 3ade114..5c8a30c 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 e197311..0b8fa17 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 572bb78..fbee717 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 b4e10b9..9e76f47 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 0b68631..08516f7 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 b649b9d..a32c512 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 40101c8..16e477e 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 c437a87..6797e84 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 cb0d8d8..fd48b52 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 6e21a6b..89200bb 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 c0ee0b4..272a201 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 29a337f..ce16655 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 d24aafd..5e25d5c 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 aa64957..3201196 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 ff7801f..6dae554 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 0181361..8ec8bb5 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 921f1c2..68c1f4a 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 4a1aeac..4fa866e 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 9a268cb..f04611a 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 48c8ec7..1d20bc8 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 fe44fa8..a3df879 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 e33b1c4..aecb2f1 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 f031273..760eedd 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 ebcb9f8..fd39127 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 7246f35..7e58753 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 c381426..55c6dd8 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 422fff1..cc94343 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 e30bc5a..f705564 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 84b5587..2f9d5e1 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 1cda42d..e9a4c20 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 bab8537..ccfdc82 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 476af90..4e7c608 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 efedc5e..9292248 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 e1f0a00..8bda1eb 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 dc0885f..21fe6ba 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 fb146e1..d2dc6b9 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 9021a3f..2ba62df 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 2e04ed7..e5cd8c0 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 9fc9baa..c6626a7 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 dedca71..57de7b0 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 82595b1..1524f73 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 8835b4e..579c5c6 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 a631100..006fd0e 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 de83518..b8925ac 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 e559f43..b551276 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 d804649..65bdbe2 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 297b0da..28b0830 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 0975f0b..37b64d1 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 40d1a8e..3264fd0 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 8451d48..dedcc11 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 840ca13..ad23e82 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 3874053..7627abb 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 9291b12..5d82880 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 b1af286..4c78ace 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 9b55195..8d9300e 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 859d51d..239bdde 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 51c1068..133c86a 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 1d1cf54..459558b 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 149adf3..68127fc 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 a12c206..b4b2c00 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 af6756c..703e2a2 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 56ff45d..1ff977f 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 1688085..2782340 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 2f40c52..b1b1e92 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 4f64215..5222a65 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 468299b..3aadcd5 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 387ab01..d1a1d7d 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 1965aec..041d051 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 615ce29..09d7cd7 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 28b4f75..6f7fcc2 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 ecde945..63ff0c3 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 d432dc9..0666369 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 0630f32..8ee8d1f 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 692cac5..a5a541e 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 0d145b7..ad0c271 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 ce5a5cd..35bb173 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 07ca719..6831f8c 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 0dbc687..ace9d9c 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 6600186..f2af1ac 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 20c649c..076bc3c 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 6d25de2..f489e50 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 c6ec68a..1bc4b9e 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 020dea5..c72fa29 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 88f8b7c..631b247 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 e995213..e6acd8e 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 266d69e..04e62fa 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 b11dfa4..e551908 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 6aaf676..4444fde 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 8577560..c337b08 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 44cd726..2c0ff68 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 b01b575..0a86be1 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 f283f8c..7c0b11a 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 5dd4bbf..337c933 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 bb4ebeb..53845bd 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 aed0247..9f7a6a9 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 c2becf7..1746335 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 970f6ad..1c1256b 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 8e71bcf..c3bf074 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 a13ca95..3fa82bb 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 0741d2c..57175ac 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 2a3e56c..82845a6 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 5cf00e0..ec4679c 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 69f4fc9..a50f1cf 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 48ca298..5ef8e1a 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 699eb76..d2ae35f 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 b391ac1..3fe6357 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 4efe884..3451a55 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 892b211..ff272f9 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 e0c3a96..41203e1 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 520c7a0..c6942da 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 209a92d..b2cbd64 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 91c3907..8415170 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 b8d8788..bc4051c 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 6b76d08..ef002bb 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 af659c7..57c7e6b 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 a4a5f69..ef1694d 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 92359e5..a7294c7 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 12fef88..1092afb 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 55d0f14..ebf8b9d 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 684fe12..8fa95e5 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 daa0e9a..eb0e23a 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 7605b8c..6c10003 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 51b233b..3e62dd4 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 0ccfe3d..a6e3015 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 f44887d..620a23e 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 ec883ad..8c07477 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 1f31be4..9d6e578 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 2e2a180..1fe1022 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 99781a2..2c34e88 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 d059c52..14448fa 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 b548d8f..ed3cc4c 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 cb4d268..226d72d 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 b099755..aa34a0c 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 005e2ef..4aac5e2 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 1bb1b37..15a0a4c 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 6ca0cd8..fba6b5e 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 1a34914..be0b5c5 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 8cedefc..1a0428b 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 a02eb0a..9f2bc45 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 b60afd8..5a7b27e 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 e38dff0..cc0efd4 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 f753d14..f5c80b1 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 2d01229..52bcc70 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 f9f3198..8d374cb 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 dde2f8e..0b9212e 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 278a45d..db3f3a5 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 2afb0d9..dae1190 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 b0f92a3..8ddc2f0 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 01bd240..b42c1d1 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 80d174c..233ba26 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 013b7b0..585f784 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 7cd1399..ffe4862 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 e599ecb..4daccdf 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 cd4f3fd..94b2693 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 4d56686..35beaf5 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 b85d9c4..d9c82e4 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 a6b7134..1bbabd8 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 95d2908..0efcee1 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 7a6032b..f6e7123 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 4e405be..c3dadc7 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 fbd72df..c61ea80 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 bb46035..da9dc85 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 d4ced3f..550b2c3 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 e168e53..c6ba142 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 5e170ca..691b17d 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 4773930..caf999f 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 bbb3c36..72f7f34 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 5cef526..c1dd7d9 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 6e66a77..a472c36 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 1fa41aa..5832737 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 a25c3bb..766306a 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 398da40..12275a4 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 0002a9e..2aff77d 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 788c3b9..b1af39d 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 214eff3..dac9314 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 8ca121d..58d05bc 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 a9ba764..436d587 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 4c537fd..e41d580 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 c5dcb7c..12d8cfd 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 d5d4480..1b63d87 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 d10b135..ddbfd2c 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 7902645..20b25aa 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 de83c69..4a421e5 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 b6f25a2..8d8f232 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 5be3047..a89b5d8 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 1b9dad5..fea28e2 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 4bc6848..05e6bcc 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 9679333..1d3ad67 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 98d9e2a..b299d3c 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 d6c3609..e8f8ee2 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 6c2f278..68362ae 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 82ab51d..d0c1c60 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 0c9c555..0a5cd91 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 f21fa54..ff6d3f9 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 33e6d74..3deb6e0 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 5bae83b..b2c3b3e 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 c3f5cdf..dfcaad5 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 3929e5c..1540b6b 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 f80eb61..85943ef 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 1511c75..7c30d4d 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 e19886d..147a092 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 e016a93..f482395 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 00dad7d..bebcd19 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 aed8860..4d1f38e 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 b15f1c2..a52b50c 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 f624f6d..36521ba 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 e03d0d0..14bc852 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 53a716d..a7544bf 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 a957473..3a522a2 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 32dbb42..2399327 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 8d99956..a1480cc 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 6ff5b47..37ef900 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 f564c9e..8f07652 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 3e03910..ea4c1fd 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 c42f547..68882db 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 bd401c1..7afd04b 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 f885cd7..717b74f 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 7680058..4b39192 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 b1674bb..6298599 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 4c07949..b71522a 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 118d990..0d6fd7c 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 718239b..0c93b88 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 f24b693..8fea713 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 c389b0b..6b57af1 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 7a6b831..7c2af3d 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 496632d..9308403 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 a6c3aff..0ca3d2c 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 6e554d2..d08ae8e 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 3cf79ce..fb6065c 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 849087e..33ac062 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 1b6c6d4..f22e9c4 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 23ceb4a..26df496 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 204c830..f8995c9 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 244df4c..47b5c71 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 43634e4..df1ea91 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 be7bb91..5130199 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 db28829..69e7aeb 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 fec5857..3491884 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 06ba3da..eefa401 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 1c22e83..deb76af 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 5356c2b..072a9bb 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 50527c0..c6cd40f 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 5ad4aff..71e0e71 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 bdb65aa..e666c77 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 e248714..d24a553 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 845bc72..725d81b 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 8ac58e4..3ddaddc 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 f22f4f2..893f2bf 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 e0a70d8..ef50dbb 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 add0a6a..2f71bea 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 3d90442..bc45404 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 5320e5e..e3dce4a 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 b918aff..12b9e90 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 9771096..5053170 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 3b4cc2f..b7d0794 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 be892b1..a097d6f 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 83990ab..2a38c83 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 7d5ec13..a61a87e 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 02458c6..b9bf3bc 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 c15583e..d99c3af 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 170c404..1cb8c76 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 ece2fb2..fc5771e 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 bcd3806..9e1c730 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 e80738a..a630ac1 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 28fb8ad..6628b28 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 0fc5084..1f23db3 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 29b97c7..b3b627f 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 39e85cf..a64cd00 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 cbdc698..31ca38b 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 bcd8d18..615fad5 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 82a11c8..4557b84 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 877aa6b..84bc383 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 cc9522e..201f3fb 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 298627e..1ce4511 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 492c043..71427c8 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 986d050..8c96684 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 08d5bb7..28bd68d 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 ce8d547..2b93150 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 69202c5..1a77c2a 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 8f6d3b1..89386f3 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 df8e7ad..bae6cdd 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 db2de06..17395bf 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 a62b977..4fdf9d7 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 85bfa4d..929c368 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 a630d2e..432157f 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 09f8285..33773bf 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 147df7f..150c6d8 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 b2ba3a7..fcf4045 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 f083c62..8e15552 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 52116dd..9c9bb22 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 100cb34..1428e68 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 08c8fc7..3f9a6ac 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 0222908..a683fdf 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 5626971..0fcf7f5 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 b038ec8..e53a3f7 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 1acd12f..02b929b 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 41d5e15..347beef 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 5e26b89..c9389d8 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 a13d57f..df2a79f 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 c78825b..22021d4 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 ec8518c..78eb451 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 2edc358..0244ebd 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 ca66f7f..4ee4096 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 18742d8..aae9fb3 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 15f95f2..d8b14bd 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 8352ec1..15ce27b 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 0000000..acec196 --- /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 0000000..bfdf652 --- /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 0000000..d2f3ef6 --- /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 0000000..0cb5e61 --- /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 0000000..5a00513 --- /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 0000000..579fba0 --- /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 0000000..8995f23 --- /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 0000000..0e87da3 --- /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 0000000..68aa518 --- /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 0000000..24acc9a --- /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 0000000..7b29359 --- /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 0000000..2b8006c --- /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 0000000..40a7dd7 --- /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 0000000..7014e7c --- /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 0000000..e5edb6f --- /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 0000000..60fdc9c --- /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 0000000..319051f --- /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 0000000..2d3e8ed --- /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 0000000..e253d8a --- /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 0000000..cc3ff25 --- /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 0000000..19f1600 --- /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 0000000..ae9c438 --- /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 0000000..84d8fa6 --- /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 0000000..d02a97e --- /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 0000000..e69b147 --- /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 0000000..412aa01 --- /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 0000000..f02d7d8 --- /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 0000000..f76dd7b --- /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 0000000..89389f9 --- /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 0000000..55c1aae --- /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 0000000..64f9288 --- /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 0000000..50c2282 --- /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 0000000..183c069 --- /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 0000000..9cb9734 --- /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 0000000..5601dd3 --- /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 0000000..e60f2e3 --- /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 0000000..9997bf5 --- /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 0000000..88ccef4 --- /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 0000000..f72d12d --- /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 0000000..0922616 --- /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 0000000..c26005a --- /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 0000000..3347e24 --- /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 0000000..098b67e --- /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 0000000..65f215d --- /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 0000000..25501b1 --- /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 0000000..c378c04 --- /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 0000000..6f0aa4d --- /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 0000000..1a51b32 --- /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 0000000..15c66a4 --- /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 0000000..431af2a --- /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 0000000..d869933 --- /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 0000000..37cc807 --- /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 0000000..b456bc4 --- /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 0000000..881f666 --- /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 0000000..c15512c --- /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 0000000..349b264 --- /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 0000000..18ceed9 --- /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 0000000..cf728a4 --- /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 0000000..ea29a5b --- /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 0000000..4aea08e --- /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 0000000..26694d1 --- /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 0000000..81da041 --- /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 0000000..8ba990c --- /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 0000000..4e87bc5 --- /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 0000000..fc5ef9c --- /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 0000000..eceb23a --- /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 0000000..e9b1e03 --- /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 0000000..0af3b9c --- /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 0000000..7ef7e3f --- /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 0000000..6e83421 --- /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 0000000..5db7201 --- /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 0000000..245eb49 --- /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 0000000..afca905 --- /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 0000000..6e15814 --- /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 0000000..005c7f0 --- /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 0000000..bc438df --- /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 0000000..7cb8288 --- /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 0000000..d627f7f --- /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 0000000..314b0e1 --- /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 0000000..7ecc1c7 --- /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 0000000..ad61ba9 --- /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 0000000..a0ed744 --- /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 0000000..ff6ebf8 --- /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 0000000..89c165b --- /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 0000000..7074f46 --- /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 0000000..b759b9d --- /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 0000000..f2f2e55 --- /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 0000000..e150204 --- /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 0000000..bbbdb73 --- /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 0000000..77b055c --- /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 0000000..922317d --- /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 0000000..a3ee70c --- /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 0000000..dff0d9c --- /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 0000000..62885ee --- /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 0000000..938b4ed --- /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 0000000..b13912b --- /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 0000000..8c38fd2 --- /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 0000000..61f7b89 --- /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 0000000..69d8b8f --- /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 0000000..80be3ae --- /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 0000000..e53a44c --- /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 0000000..d1d6445 --- /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 0000000..6eee0fd --- /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 0000000..378633a --- /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 0000000..688b4fa --- /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 0000000..0e11a73 --- /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 0000000..7348f75 --- /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 0000000..c825d66 --- /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 0000000..b0ac284 --- /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 0000000..ee6e9f0 --- /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 0000000..9c15922 --- /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 0000000..180da3b --- /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 0000000..45e3774 --- /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 0000000..445e4b5 --- /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 0000000..3b3408a --- /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 0000000..77e715a --- /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 0000000..13042f2 --- /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 0000000..ba5338b --- /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 0000000..ea0b6b9 --- /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 0000000..d91b35e --- /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 0000000..f61ed59 --- /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 0000000..84e8dd4 --- /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 0000000..8530f41 --- /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 0000000..a959879 --- /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 0000000..d4ad9f8 --- /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 0000000..90ec1d0 --- /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 0000000..42a88e0 --- /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 0000000..b104fb9 --- /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 0000000..35f5cbe --- /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 0000000..766be0e --- /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 0000000..fc9b0d4 --- /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 0000000..7dc1569 --- /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 0000000..5bc5636 --- /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 0000000..7280d5c --- /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 0000000..8260b85 --- /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 0000000..ad31d4e --- /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 0000000..91ee546 --- /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 0000000..c6fb795 --- /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 0000000..d198c4e --- /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 0000000..af4440e --- /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 0000000..493c12e --- /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 0000000..5d015cc --- /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 0000000..0fcb91d --- /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 0000000..0dadf57 --- /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 0000000..8495d34 --- /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 0000000..65cb9e3 --- /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 0000000..3155296 --- /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 0000000..3934bf4 --- /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 0000000..f736b7b --- /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 0000000..e9f412c --- /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 0000000..1aa9299 --- /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 0000000..bfac549 --- /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 0000000..9c75dd4 --- /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 0000000..05d2a07 --- /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 0000000..2b01761 --- /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 0000000..834d3bd --- /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 0000000..c819ba2 --- /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 0000000..4164cd3 --- /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 0000000..7105f73 --- /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 0000000..d4eaed9 --- /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 0000000..a0dfc9f --- /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 0000000..3ffc983 --- /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 0000000..fcfade6 --- /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 0000000..8fcda99 --- /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 0000000..e1acd2d --- /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 0000000..5c61c2b --- /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 0000000..fa8715c --- /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 0000000..623ae0b --- /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 0000000..f15d5e2 --- /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 0000000..5a09fc6 --- /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 0000000..2a74da9 --- /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 0000000..5a7a271 --- /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 0000000..43aa1e4 --- /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 0000000..89cd9de --- /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 0000000..1b55ce3 --- /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 0000000..08292a4 --- /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 0000000..07250c5 --- /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 0000000..7042398 --- /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 0000000..a30d1ee --- /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 0000000..4d6ae32 --- /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 0000000..5c020ad --- /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 0000000..2b38715 --- /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 0000000..fd9f178 --- /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 0000000..a4ff468 --- /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 0000000..667d124 --- /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 0000000..a1604a5 --- /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 0000000..3b2baa5 --- /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 0000000..b18f895 --- /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 0000000..fa398cc --- /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 0000000..7f1035c --- /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 0000000..a39bb1f --- /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 0000000..6754771 --- /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 0000000..e50c141 --- /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 0000000..e6e441e --- /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 0000000..f96f4cf --- /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 0000000..a015894 --- /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 0000000..b40b212 --- /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 0000000..3a4beff --- /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 0000000..9cca324 --- /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 0000000..5f990c2 --- /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 0000000..804aced --- /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 0000000..722eff8 --- /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 0000000..6ab02ed --- /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 0000000..edad5e1 --- /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 0000000..3fbce89 --- /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 0000000..6d2245d --- /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 0000000..144d262 --- /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 0000000..9455a98 --- /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 0000000..3c703c8 --- /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 0000000..290e988 --- /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 0000000..fd00b13 --- /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 0000000..07196fd --- /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 0000000..b4d2802 --- /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 0000000..7ae098b --- /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 0000000..e3c950e --- /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 0000000..631b8e2 --- /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 0000000..8336281 --- /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 0000000..7896c2a --- /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 0000000..250405a --- /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 0000000..1a255cc --- /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 0000000..b871337 --- /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 0000000..a3536b6 --- /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 0000000..c25b59e --- /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 0000000..fd6819e --- /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 0000000..e931d9f --- /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 0000000..378ba78 --- /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 0000000..f100e4b --- /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 0000000..f8858f0 --- /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 0000000..9148229 --- /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 0000000..23a37da --- /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 0000000..7a2c6f5 --- /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 0000000..eae584e --- /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 0000000..5aaeb25 --- /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 0000000..40598c6 --- /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 0000000..c2327c1 --- /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 0000000..b033ed6 --- /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 0000000..a5a8740 --- /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 0000000..0fc415b --- /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 0000000..f8cdb9f --- /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 0000000..1b61c14 --- /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 0000000..bd91a9f --- /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 0000000..eafb81b --- /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 0000000..cd3a6c2 --- /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 0000000..4c2ac39 --- /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 0000000..2b049a4 --- /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 0000000..10d52fd --- /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 0000000..907ed97 --- /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 0000000..9766fc4 --- /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 0000000..5d49761 --- /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 0000000..2732e1b --- /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 0000000..1622d69 --- /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 0000000..78ed463 --- /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 0000000..313551a --- /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 0000000..d76d4c9 --- /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 0000000..6f007e2 --- /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 0000000..44df948 --- /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 0000000..a82638d --- /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 0000000..89ecace --- /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 0000000..740485d --- /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 0000000..b2556ab --- /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 0000000..e71e46d --- /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 0000000..ac3a028 --- /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 0000000..685ac54 --- /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 0000000..ec15210 --- /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 0000000..8f0e42f --- /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 0000000..d69315a --- /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 0000000..c388270 --- /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 0000000..c1740c9 --- /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 0000000..4083788 --- /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 0000000..7fca6ae --- /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 0000000..164f5b8 --- /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 0000000..ecd417a --- /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 0000000..2ba94ef --- /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 0000000..321d663 --- /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 0000000..0d9a20a --- /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 0000000..82b0265 --- /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 0000000..7a8f704 --- /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 0000000..1208918 --- /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 0000000..8612eb9 --- /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 0000000..dc21a92 --- /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 0000000..6cc3351 --- /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 0000000..0d82246 --- /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 0000000..c11b991 --- /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 0000000..1e53149 --- /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 0000000..a7ebad2 --- /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 0000000..6cea364 --- /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 0000000..c362dc9 --- /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 0000000..4a17d9a --- /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 0000000..af17fd5 --- /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 0000000..eca1ffa --- /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 0000000..223d09a --- /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 0000000..5d1d04c --- /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 0000000..b2d56c2 --- /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 0000000..e76ff3e --- /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 0000000..8241f4e --- /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 0000000..d58fcd9 --- /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 0000000..65543c8 --- /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 0000000..5ef376e --- /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 0000000..7c97623 --- /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 0000000..f8d6b7f --- /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 0000000..8c858da --- /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 0000000..973f27a --- /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 0000000..e2b2494 --- /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 0000000..b605532 --- /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 0000000..8b80a9b --- /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 0000000..b456034 --- /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 0000000..d0d5e7f --- /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 0000000..120db9c --- /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 0000000..99ed7b2 --- /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 0000000..0ed2fda --- /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 0000000..a16300c --- /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 0000000..c196337 --- /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 0000000..91caa12 --- /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 0000000..a2c7a05 --- /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 0000000..fd8cca4 --- /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 0000000..b2a3fe7 --- /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 0000000..1e6d9d8 --- /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 0000000..7fcfeff --- /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 0000000..beff337 --- /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 0000000..e8c63da --- /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 0000000..2b4b7a5 --- /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 0000000..493f66a --- /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 0000000..500b726 --- /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 0000000..e6dd9b3 --- /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 0000000..4fbd319 --- /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 0000000..6628ccf --- /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 0000000..7b7b6cb --- /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 0000000..7713e43 --- /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 0000000..be812bd --- /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 0000000..995fea9 --- /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 0000000..c63ff4d --- /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 0000000..134982a --- /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 0000000..3fed504 --- /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 0000000..413f2b1 --- /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 0000000..9a51f64 --- /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 0000000..50b5624 --- /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 0000000..3166fdd --- /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 0000000..0fc1653 --- /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 0000000..6de9a6d --- /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 0000000..8083916 --- /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 0000000..d9171bc --- /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 0000000..740bfcd --- /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 0000000..26587ac --- /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 0000000..2df1f29 --- /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 0000000..2031d39 --- /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 0000000..691e14c --- /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 0000000..2b117a3 --- /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 0000000..ee1a8ef --- /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 0000000..40da97c --- /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 0000000..1bab8d1 --- /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 0000000..92b375a --- /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 0000000..15e72e1 --- /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 0000000..8dbc8ff --- /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 0000000..5a89400 --- /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 0000000..64841d0 --- /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 0000000..1f525e9 --- /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 0000000..bf870f3 --- /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 0000000..bb6186c --- /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 0000000..9ccb8bb --- /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 0000000..c220cb3 --- /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 0000000..edfdbed --- /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 0000000..1206a30 --- /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 0000000..b6b4b81 --- /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 0000000..2582a72 --- /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 0000000..dad29c2 --- /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 0000000..8a845a7 --- /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 0000000..a6430c7 --- /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 0000000..b637988 --- /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 0000000..eea4d32 --- /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 0000000..79e606c --- /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 0000000..746b2dd --- /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 0000000..0992779 --- /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 0000000..0c0437e --- /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 0000000..c45d106 --- /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 0000000..e9d3f72 --- /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 0000000..b76efe4 --- /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 0000000..ec50aa0 --- /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 0000000..57f6ec4 --- /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 0000000..7aa068c --- /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 0000000..7297407 --- /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 0000000..6b9f671 --- /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 0000000..985b664 --- /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 0000000..8692ce8 --- /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 0000000..7331443 --- /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 0000000..41b83ba --- /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 0000000..feadbbb --- /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 0000000..b3d5552 --- /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 0000000..e484e85 --- /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 0000000..e34462e --- /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 0000000..91d6266 --- /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 0000000..1b78d29 --- /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 0000000..58d543f --- /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 0000000..dc78e2e --- /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 0000000..f9ddbfe --- /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 0000000..b6adea0 --- /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 0000000..e9f4d62 --- /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 0000000..469bc2f --- /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 0000000..941770e --- /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 0000000..21ef474 --- /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 0000000..2666bf1 --- /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 0000000..94bc808 --- /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 0000000..4d4e229 --- /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 0000000..1e6b6ed --- /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 0000000..145f988 --- /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 0000000..dbffa5d --- /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 0000000..b4fcf8e --- /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 0000000..54ae928 --- /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 0000000..f60e49b --- /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 0000000..ba041a4 --- /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 0000000..1bb8dad --- /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 0000000..e6f3a4d --- /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 0000000..87107d2 --- /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 0000000..8c018a5 --- /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 0000000..5e573f7 --- /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 0000000..11902e6 --- /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 0000000..1ad8c26 --- /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 0000000..fcc5636 --- /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 0000000..46751f4 --- /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 0000000..34d6784 --- /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 0000000..f6d07db --- /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 0000000..98778eb --- /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 0000000..e7c49db --- /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 0000000..4ec9eff --- /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 0000000..a880836 --- /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 0000000..80b4b59 --- /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 0000000..b160709 --- /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 0000000..8be0de2 --- /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 0000000..cd94c7a --- /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 0000000..a59f521 --- /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 0000000..75aa30a --- /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 0000000..2a575a0 --- /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 0000000..9439373 --- /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 0000000..fe1d5a7 --- /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 0000000..6f605ba --- /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 0000000..cf9e67e --- /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 0000000..94cdcfd --- /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 0000000..b3b77ec --- /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 0000000..bb50b80 --- /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 0000000..91a16bd --- /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 0000000..7ca5a9a --- /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 0000000..5d65b31 --- /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 0000000..521c047 --- /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 0000000..74a7f93 --- /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 0000000..0de62a3 --- /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 0000000..22d57b8 --- /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 0000000..3ed551a --- /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 0000000..58e6e43 --- /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 0000000..23cd2c7 --- /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 0000000..b460c8d --- /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 0000000..d275eed --- /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 0000000..fcefd8e --- /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 0000000..cc47e99 --- /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 0000000..269f6aa --- /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 0000000..e06a115 --- /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 0000000..3e13533 --- /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 0000000..e1837d0 --- /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 0000000..b4fc005 --- /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 0000000..618515d --- /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 0000000..bd3bffc --- /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 0000000..21d80bd --- /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 0000000..b7b23d5 --- /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 0000000..445f77f --- /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 0000000..d025d7c --- /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 0000000..9ed6b6f --- /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 0000000..68c8c71 --- /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 0000000..fbc9b9f --- /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 0000000..5679e7e --- /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 0000000..66c3561 --- /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 0000000..66b3a92 --- /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 0000000..bd858d0 --- /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 0000000..fdd1ac5 --- /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 0000000..e3ab7cd --- /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 0000000..2282b1a --- /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 0000000..9ad2eff --- /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 0000000..b0db2eb --- /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 0000000..a56aff0 --- /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 0000000..05fc664 --- /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 0000000..de76e7c --- /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 0000000..198150e --- /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 0000000..cf30c44 --- /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 0000000..42ae946 --- /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 0000000..2cecf5c --- /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 0000000..3f7d964 --- /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 0000000..6f6ee78 --- /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 0000000..c43e4aa --- /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 0000000..073fd1f --- /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 0000000..d692760 --- /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 0000000..3495742 --- /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 0000000..06792a0 --- /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 0000000..e0ee9de --- /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 0000000..a45d71e --- /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 0000000..b22c328 --- /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 0000000..61b13a9 --- /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 0000000..2826765 --- /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 0000000..d3f8341 --- /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 0000000..e142890 --- /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 0000000..b401eef --- /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 0000000..e0c18a5 --- /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 0000000..4b2fa23 --- /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 0000000..86762ad --- /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 0000000..ac98566 --- /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 0000000..448e56c --- /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 0000000..f366e82 --- /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 0000000..b63f083 --- /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 0000000..d1f5440 --- /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 0000000..fc84c7f --- /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 0000000..75f9b06 --- /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 0000000..195b6d6 --- /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 0000000..a82c66f --- /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 0000000..08a81ef --- /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 0000000..f6ec5f0 --- /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 0000000..bf5bd4e --- /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 0000000..a55cbee --- /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 0000000..cdfbc27 --- /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 0000000..cc09959 --- /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 0000000..de88043 --- /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 0000000..d4c561e --- /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 0000000..15698a1 --- /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 0000000..fe036db --- /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 0000000..70b87f9 --- /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 0000000..ac04f35 --- /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 0000000..98d60bf --- /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 0000000..e25ee33 --- /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 0000000..36924a6 --- /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 0000000..ea4e512 --- /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 0000000..c85e35a --- /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 0000000..4e14b00 --- /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 0000000..931bf5e --- /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 0000000..675c311 --- /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 0000000..749019e --- /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 0000000..704395a --- /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 0000000..0cd9a33 --- /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 0000000..1a5cae6 --- /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 0000000..9955821 --- /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 0000000..b370ea7 --- /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 0000000..307be3c --- /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 0000000..e04b791 --- /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 0000000..c7515cb --- /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 0000000..57377b0 --- /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 0000000..1db0184 --- /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 0000000..f003992 --- /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 0000000..f253db7 --- /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 0000000..ca8a482 --- /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 0000000..5152813 --- /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 0000000..2059f0e --- /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 0000000..a8991c2 --- /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 0000000..8a8bb51 --- /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 0000000..dbd1ac2 --- /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 0000000..c95bf39 --- /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 0000000..6967351 --- /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 0000000..dd96a06 --- /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 0000000..6c6f7ec --- /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 0000000..aa1c02f --- /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 0000000..689fdf3 --- /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 0000000..5f7507d --- /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 0000000..fb9c8b8 --- /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 0000000..70c6dc1 --- /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 0000000..ba3ec88 --- /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 0000000..5aa77ab --- /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 0000000..164b176 --- /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 0000000..9175252 --- /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 0000000..fccf5a6 --- /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 0000000..f03186c --- /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 0000000..316c4d1 --- /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 0000000..0801b59 --- /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 0000000..20ebddd --- /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 0000000..8130e1f --- /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 0000000..c5a91e1 --- /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 0000000..43f4049 --- /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 0000000..4541148 --- /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 0000000..f433771 --- /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 0000000..3791c67 --- /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 0000000..51d5cbe --- /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 0000000..93d06f6 --- /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 0000000..e644046 --- /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 0000000..4d0492f --- /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 0000000..d8d6db1 --- /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 0000000..a9b303b --- /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 0000000..55228ff --- /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 0000000..be8172a --- /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 0000000..fbdbef7 --- /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 0000000..8ef71f9 --- /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 0000000..0554cbe --- /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 0000000..7f788c3 --- /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 0000000..f311889 --- /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 0000000..1e13fe4 --- /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 0000000..95f343c --- /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 0000000..dfaa231 --- /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 0000000..8652f17 --- /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 0000000..eb6e2c2 --- /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 0000000..5c50e0d --- /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 0000000..2cbe65c --- /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 0000000..1ba12c5 --- /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 0000000..6da3b3f --- /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 0000000..06d32ec --- /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 0000000..f397f9f --- /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 0000000..2877e3a --- /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 0000000..cf45794 --- /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 0000000..ce5a3e4 --- /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 0000000..4703754 --- /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 0000000..bf57425 --- /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 0000000..a9d9499 --- /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 0000000..cf93c09 --- /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 0000000..f5e2301 --- /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 0000000..404c38d --- /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 0000000..c6af728 --- /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 0000000..844ff64 --- /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 0000000..f6b8142 --- /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 0000000..23187dd --- /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 0000000..4f8e3f4 --- /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 0000000..c2f2078 --- /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 0000000..ce486ba --- /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 0000000..c388075 --- /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 0000000..520ab9a --- /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 0000000..4d65547 --- /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 0000000..ed11009 --- /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 0000000..10f0507 --- /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 0000000..b2604e5 --- /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 0000000..5d8d10a --- /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 0000000..fdc17fd --- /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 0000000..a0adce1 --- /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 0000000..7cfb35e --- /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 0000000..05d7df1 --- /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 0000000..b465106 --- /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 0000000..a330a5a --- /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 0000000..328d987 --- /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 0000000..59e5f73 --- /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 0000000..0611196 --- /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 0000000..b7405d2 --- /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 0000000..994c35b --- /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 0000000..e1a4876 --- /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 0000000..bbe128b --- /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 0000000..2160f6e --- /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 0000000..ed86ca4 --- /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 0000000..dcf10d8 --- /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 0000000..96c70fd --- /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 0000000..44c0dae --- /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 0000000..1a41a22 --- /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 0000000..e8cae48 --- /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 0000000..4dcd64d --- /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 0000000..57f4ec5 --- /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 0000000..17b0d82 --- /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 0000000..5d9c4b1 --- /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 0000000..cb6d86d --- /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 0000000..8487b3c --- /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 0000000..0030e23 --- /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 0000000..35a4331 --- /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 0000000..633806f --- /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 0000000..45be393 --- /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 0000000..ec50942 --- /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 0000000..165236b --- /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 0000000..3f3cf08 --- /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 0000000..de150f2 --- /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 0000000..6201b51 --- /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 0000000..89818f6 --- /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 0000000..32f5aa2 --- /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 0000000..7341b71 --- /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 0000000..ff8305a --- /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 0000000..f062980 --- /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 0000000..ee212a0 --- /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 0000000..a7b9d24 --- /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 0000000..0fabbe8 --- /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 0000000..a2ba42b --- /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 0000000..1cdb745 --- /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 0000000..3c82ee0 --- /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 0000000..1d2c98b --- /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 0000000..1018a6d --- /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 0000000..8e68d24 --- /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 0000000..b5ce34d --- /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 0000000..939303f --- /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 0000000..5096dc1 --- /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 0000000..16bc41d --- /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 0000000..e104a60 --- /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 0000000..9243b2a --- /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 0000000..2daa9f9 --- /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 0000000..1fd6494 --- /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 0000000..5f9e626 --- /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 0000000..3b6b231 --- /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 0000000..c51a978 --- /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 0000000..8bb52c8 --- /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 0000000..c0f1dc1 --- /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 0000000..a43e069 --- /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 0000000..257e6a1 --- /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 0000000..4f851da --- /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 0000000..4ceec17 --- /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 0000000..61b88f4 --- /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 0000000..8daa629 --- /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 0000000..baf541e --- /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 0000000..83095a6 --- /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 0000000..681396b --- /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 0000000..29ff4bc --- /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 0000000..1eecd03 --- /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 0000000..b8f158e --- /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 0000000..db9f6f0 --- /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 0000000..d445912 --- /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 0000000..c044bfb --- /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 0000000..b3de4b3 --- /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 0000000..0128158 --- /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 0000000..3494571 --- /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 0000000..acaf48d --- /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 0000000..64cc926 --- /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 0000000..b38c7b4 --- /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 0000000..1096a00 --- /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 0000000..061b0cd --- /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 0000000..2888ee4 --- /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 0000000..07c2a8d --- /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 0000000..1b48fa8 --- /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 0000000..6386ac8 --- /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 0000000..0cc6e35 --- /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 0000000..bcd5e20 --- /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 0000000..1f04eee --- /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 0000000..88710e7 --- /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 0000000..06d1b17 --- /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 0000000..ef48555 --- /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 0000000..05e4823 --- /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 0000000..5151147 --- /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 0000000..16680ec --- /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 0000000..0fdfdf0 --- /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 0000000..997a423 --- /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 0000000..ea5b2a3 --- /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 0000000..146b18a --- /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 0000000..4629bb2 --- /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 0000000..3650247 --- /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 0000000..57ec0d8 --- /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 0000000..902a427 --- /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 0000000..37a4fa6 --- /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 0000000..3ab67a8 --- /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 0000000..f91a275 --- /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 0000000..f1f380e --- /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 0000000..f46e7f5 --- /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 0000000..ce8c2d8 --- /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 0000000..035115a --- /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 0000000..7c80b67 --- /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 0000000..ad898b4 --- /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 0000000..2600d39 --- /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 0000000..f2b8725 --- /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 0000000..a747895 --- /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 0000000..e677214 --- /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 0000000..bdf53f6 --- /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 0000000..0158805 --- /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 0000000..f6ea5ac --- /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 0000000..d7ffda1 --- /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 0000000..4f60232 --- /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 0000000..ed0ccf1 --- /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 0000000..0284d6e --- /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 0000000..41d3ec2 --- /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 0000000..abe12a2 --- /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 0000000..e77f3f9 --- /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 0000000..db47e8f --- /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 0000000..38d79ad --- /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 0000000..5902f72 --- /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 0000000..961422e --- /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 0000000..f0940cb --- /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 0000000..64b2c30 --- /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 0000000..b89c63a --- /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 0000000..9cce318 --- /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 0000000..7eee1af --- /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 0000000..835d2a8 --- /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 0000000..3ac50a1 --- /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 0000000..6af171c --- /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 0000000..e6ff36b --- /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 0000000..ae40572 --- /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 0000000..acf9871 --- /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 0000000..02afc08 --- /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 0000000..4d31776 --- /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 0000000..660aef8 --- /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 0000000..fd9e0fb --- /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 0000000..0b99164 --- /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 0000000..4831e2d --- /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 0000000..0d4e1f8 --- /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 0000000..853f639 --- /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 0000000..0f9af41 --- /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 0000000..5852412 --- /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 0000000..4b523f0 --- /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 0000000..0b8f91e --- /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 0000000..55d9d61 --- /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 0000000..ba41a1e --- /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 0000000..3af2894 --- /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 0000000..4b00af5 --- /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 0000000..f89764b --- /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 0000000..55064df --- /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 0000000..ec10d31 --- /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 0000000..ee853e6 --- /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 0000000..17aa323 --- /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 0000000..e2bc748 --- /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 0000000..2f5b957 --- /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 0000000..7071a39 --- /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 0000000..92608dd --- /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 0000000..bc1fcfc --- /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 0000000..60ce5c9 --- /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 0000000..8dcc978 --- /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 0000000..7042ce7 --- /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 0000000..15c36b2 --- /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 0000000..ffb8f9f --- /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 0000000..3c6c040 --- /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 0000000..2504eeb --- /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 0000000..25ba0b7 --- /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 0000000..0b9f718 --- /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 0000000..74d6dff --- /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 0000000..1d73241 --- /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 0000000..f9b9bef --- /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 0000000..1314ddf --- /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 0000000..2b13d91 --- /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 0000000..68512ee --- /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 0000000..b3c5287 --- /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 0000000..3fe9ae9 --- /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 0000000..f08ed05 --- /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 0000000..69487e2 --- /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 0000000..7b9132b --- /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 0000000..1b234bc --- /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 0000000..3a823a8 --- /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 0000000..823bea1 --- /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 0000000..f887f27 --- /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 0000000..9e8e6ff --- /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 0000000..018dc61 --- /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 0000000..4d0d725 --- /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 0000000..b8ec2c5 --- /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 0000000..c53af66 --- /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 0000000..3e54601 --- /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 0000000..749c618 --- /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 0000000..b10e08f --- /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 0000000..5afea30 --- /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 0000000..334d036 --- /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 0000000..f9420cd --- /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 0000000..d03b2a5 --- /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 0000000..f36aded --- /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 0000000..4beabce --- /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 0000000..e9a6531 --- /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 0000000..b1ff03e --- /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 0000000..fe5c284 --- /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 0000000..8f96c0b --- /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 0000000..791ede6 --- /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 0000000..5dd59da --- /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 0000000..d327e7b --- /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 0000000..1c63743 --- /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 0000000..7cc0766 --- /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 0000000..c607c29 --- /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 0000000..eddf8d9 --- /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 0000000..b241129 --- /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 0000000..bdec582 --- /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 0000000..d2802dd --- /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 0000000..84960a0 --- /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 0000000..e53ad8b --- /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 0000000..2070791 --- /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 0000000..3fd1cf8 --- /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 0000000..e218c00 --- /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 0000000..ed59012 --- /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 0000000..093968a --- /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 0000000..45fc82e --- /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 0000000..48918ca --- /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 0000000..faacd5c --- /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 0000000..1c75b92 --- /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 0000000..7332eb8 --- /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 0000000..767f845 --- /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 0000000..12963e3 --- /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 0000000..9b808c2 --- /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 0000000..e6ea401 --- /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 0000000..d2a2f93 --- /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 0000000..d48cf5d --- /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 0000000..48894cb --- /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 0000000..63ca28c --- /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 0000000..1f194d9 --- /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 0000000..7731c26 --- /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 0000000..3390a42 --- /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 0000000..8469d8c --- /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 0000000..6ad8524 --- /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 0000000..60d58b6 --- /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 0000000..455018d --- /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 0000000..f08a1b3 --- /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 0000000..1cce363 --- /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 0000000..e89454e --- /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 0000000..68ddd43 --- /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 0000000..863c4c6 --- /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 0000000..b9c0c2e --- /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 0000000..bbbdb91 --- /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 0000000..cd22b71 --- /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 0000000..0330630 --- /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 0000000..7f74bec --- /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 0000000..7631216 --- /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 0000000..dbe75c9 --- /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 0000000..f6eb00b --- /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 0000000..a084760 --- /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 0000000..1565adb --- /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 0000000..78c6762 --- /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 0000000..c37177a --- /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 0000000..e754175 --- /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 0000000..c37a287 --- /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 0000000..ea16672 --- /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 0000000..44e1eb6 --- /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 0000000..42311f5 --- /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 0000000..26fcfe8 --- /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 0000000..d6a70e0 --- /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 0000000..5e1ab17 --- /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 0000000..22c762e --- /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 0000000..9beb5db --- /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 0000000..deb5073 --- /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 0000000..93f80de --- /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 0000000..454c112 --- /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 0000000..3dbb6ea --- /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 0000000..404c9fe --- /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 0000000..4fbcf4e --- /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 0000000..156b2d0 --- /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 0000000..945394c --- /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 0000000..202518e --- /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 0000000..f68808b --- /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 0000000..f8e64f6 --- /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 0000000..e3cdb3e --- /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 0000000..d55708b --- /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 0000000..6288454 --- /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 0000000..a78f98a --- /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 0000000..2cab666 --- /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 0000000..3d0f49e --- /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 0000000..93eb4ad --- /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 0000000..5595322 --- /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 0000000..b16c718 --- /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 0000000..2d9710c --- /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 0000000..5e4af54 --- /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 0000000..e760567 --- /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 0000000..e8b34e9 --- /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 0000000..4a66f5e --- /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 0000000..51cf39d --- /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 0000000..d989bdd --- /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 0000000..3f54374 --- /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 0000000..c28e086 --- /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 0000000..8cbf370 --- /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 0000000..c371663 --- /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 0000000..4d94ed8 --- /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 0000000..f3a2bf2 --- /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 0000000..6d383a1 --- /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 0000000..9063ee6 --- /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 0000000..236f2e5 --- /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 0000000..f161099 --- /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 0000000..564fa6d --- /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 0000000..c822489 --- /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 0000000..9bf0976 --- /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 0000000..88d8620 --- /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 0000000..13465eb --- /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 0000000..0ef7056 --- /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 0000000..65c382d --- /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 0000000..aff35e4 --- /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 0000000..704c6c7 --- /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 0000000..3e3cf41 --- /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 0000000..b4401eb --- /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 0000000..34ce038 --- /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 0000000..ba49d03 --- /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 0000000..5184319 --- /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 0000000..34f4442 --- /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 0000000..4366303 --- /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 0000000..f8a9381 --- /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 0000000..eee6352 --- /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 0000000..ee3aab5 --- /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 0000000..aa57c33 --- /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 0000000..138e700 --- /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 0000000..cea732d --- /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 0000000..b04c279 --- /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 0000000..a3e946b --- /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 0000000..3250c2f --- /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 0000000..3c95c44 --- /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 0000000..516c330 --- /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 0000000..ef4ff1d --- /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 0000000..c35bd5b --- /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 0000000..d662e93 --- /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 0000000..beed9eb --- /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 0000000..9da7f67 --- /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 0000000..162b171 --- /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 0000000..5673096 --- /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 0000000..c2d5577 --- /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 0000000..b276cb4 --- /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 0000000..c993903 --- /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 0000000..3172819 --- /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 0000000..e7ca1a5 --- /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 0000000..76f8c2f --- /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 0000000..d110220 --- /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 0000000..507110a --- /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 0000000..c3617a0 --- /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 0000000..b9b9530 --- /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 0000000..2ec20cb --- /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 0000000..ca2e097 --- /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 0000000..92c905a --- /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 0000000..87ff872 --- /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 0000000..b3d9eb2 --- /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 0000000..45e3472 --- /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 0000000..471c4ba --- /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 0000000..65879a5 --- /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 0000000..f1a064c --- /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 0000000..b3e2fb2 --- /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 0000000..82732e2 --- /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 0000000..6dace85 --- /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 0000000..fecec21 --- /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 0000000..7d1c8d7 --- /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 0000000..0aa17e0 --- /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 0000000..d1a817c --- /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 0000000..f3b764e --- /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 0000000..8b9cea2 --- /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 0000000..1060ef8 --- /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 0000000..276161d --- /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 0000000..639f605 --- /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 0000000..80ab689 --- /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 0000000..563882d --- /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 0000000..9d19eeb --- /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 0000000..d567aca --- /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 0000000..a338548 --- /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 0000000..4763ea6 --- /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 0000000..f8b9f2b --- /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 0000000..3119d04 --- /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 0000000..b8f464b --- /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 0000000..3597e55 --- /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 0000000..bdeb731 --- /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 0000000..790474b --- /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 0000000..55047be --- /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 0000000..174909a --- /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 0000000..141fe48 --- /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 0000000..6fd95bd --- /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 0000000..f747a1f --- /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 0000000..7129333 --- /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 0000000..a49c737 --- /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 0000000..8866aa4 --- /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 0000000..4afc378 --- /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 0000000..d2f40ed --- /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 0000000..c8872d0 --- /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 0000000..2ff19a3 --- /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 0000000..016e08d --- /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 0000000..12f09bc --- /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 0000000..9674ddc --- /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 0000000..35a0414 --- /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 0000000..ae28fbb --- /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 0000000..7d46d90 --- /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 0000000..fe17387 --- /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 0000000..938dc78 --- /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 0000000..c1dadf6 --- /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 0000000..a433427 --- /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 0000000..ddfb52a --- /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 0000000..596eb85 --- /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 0000000..59abebf --- /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 0000000..f6f297a --- /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 0000000..4d559bf --- /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 0000000..71352d9 --- /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 0000000..5734f28 --- /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 0000000..e8b122f --- /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 0000000..309efa8 --- /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 0000000..b96bc5c --- /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 0000000..26a0d25 --- /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 0000000..0a6520f --- /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 0000000..108bb45 --- /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 0000000..6639bde --- /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 0000000..e234f34 --- /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 0000000..073a0bc --- /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 0000000..18d2763 --- /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 0000000..28ef0f0 --- /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 0000000..106a258 --- /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 0000000..0257f78 --- /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 0000000..551c9c5 --- /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 0000000..1c4d235 --- /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 0000000..a75238f --- /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 0000000..b771286 --- /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 0000000..2792127 --- /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 0000000..00d63c3 --- /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 0000000..9671768 --- /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 0000000..d88dbe3 --- /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 0000000..857a90b --- /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 0000000..64d7571 --- /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 0000000..03428a7 --- /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 0000000..3a21bbb --- /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 0000000..fbab976 --- /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 0000000..719a508 --- /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 0000000..a314556 --- /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 0000000..eb788cf --- /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 0000000..18fb782 --- /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 0000000..485f3a1 --- /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 0000000..ac4c343 --- /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 0000000..dee9f24 --- /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 0000000..30974f7 --- /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 0000000..c1acccb --- /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 0000000..1946ef7 --- /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 0000000..e7817e7 --- /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 0000000..b2be605 --- /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 0000000..bacb5c0 --- /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 0000000..4142661 --- /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 0000000..ba99dbc --- /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 0000000..d9c7b8d --- /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 0000000..4391066 --- /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 0000000..9df49d5 --- /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 0000000..fb73032 --- /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 0000000..9dc257a --- /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 0000000..77d5ddb --- /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 0000000..7decf8d --- /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 0000000..a910a9a --- /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 0000000..1640988 --- /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 0000000..bd2ab0a --- /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 0000000..3be5f74 --- /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 0000000..f3323a8 --- /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 0000000..2a7ce5e --- /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 0000000..fb7e7ea --- /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 0000000..34ce71a --- /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 0000000..3751aab --- /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 0000000..f9de433 --- /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 0000000..a951075 --- /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 0000000..cac872a --- /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 0000000..a130569 --- /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 0000000..58a634d --- /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 0000000..db46242 --- /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 0000000..faa55bf --- /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 0000000..d45d075 --- /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 0000000..83470ca --- /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 0000000..1235f39 --- /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 0000000..8157a66 --- /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 0000000..c349bb8 --- /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 0000000..70ff43e --- /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 0000000..c737f8c --- /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 0000000..45b888b --- /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 0000000..ef9e54d --- /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 0000000..df61026 --- /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 0000000..419ae72 --- /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 0000000..2f27027 --- /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 0000000..39776a8 --- /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 0000000..8a6b4c7 --- /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 0000000..07d9038 --- /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 0000000..1512fbf --- /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 0000000..7595546 --- /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 0000000..285f36c --- /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 0000000..38883eb --- /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 0000000..9e320af --- /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 0000000..c9198d6 --- /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 0000000..1697fcf --- /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 0000000..e89ed08 --- /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 0000000..40b4ab0 --- /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 0000000..295f43b --- /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 0000000..abe7b8f --- /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 0000000..d2ae292 --- /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 0000000..5d5d3c8 --- /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 0000000..33eb074 --- /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 0000000..684e3af --- /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 0000000..6a8a090 --- /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 0000000..d64bcb9 --- /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 0000000..79198ab --- /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 0000000..95a4098 --- /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 0000000..61c4a2e --- /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 0000000..98674b6 --- /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 0000000..c705db7 --- /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 0000000..4ad1f4c --- /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 0000000..01b94f7 --- /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 0000000..d8e4fde --- /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 0000000..378ad2c --- /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 0000000..24bc361 --- /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 0000000..32b1a53 --- /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 0000000..1865d49 --- /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 0000000..9a6287a --- /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 0000000..2855560 --- /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 0000000..90db6ba --- /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 0000000..240e8fa --- /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 0000000..8231b83 --- /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 0000000..22d1322 --- /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 0000000..b4fb30f --- /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 0000000..328b7f4 --- /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 0000000..7888a82 --- /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 0000000..0c3255e --- /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 0000000..1e6798e --- /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 0000000..44f6ff5 --- /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 0000000..006e531 --- /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 0000000..b1730e0 --- /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 0000000..5c62fba --- /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 0000000..08b21c5 --- /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 0000000..c455e3e --- /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 0000000..2e3cc5c --- /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 0000000..d5faa53 --- /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 0000000..00e9f6d --- /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 0000000..25df8c9 --- /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 0000000..8c0dcde --- /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 0000000..973ac7b --- /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 0000000..aeb55e5 --- /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 0000000..804db66 --- /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 0000000..0b0f670 --- /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 0000000..87bf3b4 --- /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 0000000..b01dab6 --- /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 0000000..3b05265 --- /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 0000000..3f06311 --- /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 0000000..b141aa4 --- /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 0000000..73ffee6 --- /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 0000000..218fec8 --- /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 0000000..5195972 --- /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 0000000..f6b114e --- /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 0000000..9a71c8d --- /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 0000000..479eb2f --- /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 0000000..4dc5747 --- /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 0000000..7ed7885 --- /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 0000000..729fbd9 --- /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 0000000..389919b --- /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 0000000..e01316d --- /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 0000000..2a658d8 --- /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 0000000..1f39e0c --- /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 0000000..893d43f --- /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 0000000..ec6e004 --- /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 0000000..91069cc --- /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 0000000..5a20088 --- /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 0000000..b9060ce --- /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 0000000..3c70857 --- /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 0000000..d7bcee3 --- /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 0000000..364877d --- /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 0000000..b64dd32 --- /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 0000000..f858358 --- /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 0000000..f1ddd7b --- /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 0000000..141142b --- /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 0000000..c211ef3 --- /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 0000000..6f1e59a --- /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 0000000..17de885 --- /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 0000000..6f43a62 --- /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 0000000..2202f0b --- /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 0000000..be49515 --- /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 0000000..3d83b55 --- /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 0000000..b70fe28 --- /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 0000000..dc6118f --- /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 0000000..9f78d65 --- /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 0000000..2b1b3b2 --- /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 0000000..62a3f27 --- /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 0000000..efb2fca --- /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 0000000..b76a99e --- /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 0000000..926ba01 --- /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 0000000..87161fe --- /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 0000000..9f7198f --- /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 0000000..77a59d2 --- /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 0000000..9dbef33 --- /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 0000000..70a196d --- /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 0000000..22f9f1a --- /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 0000000..5a3b390 --- /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 0000000..bd80c9d --- /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 0000000..4fc8da1 --- /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 0000000..caf1676 --- /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 0000000..802bc70 --- /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 0000000..9635e0c --- /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 0000000..5fefa74 --- /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 0000000..a08a33d --- /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 0000000..65be4f5 --- /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 0000000..5164fe6 --- /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 0000000..cf3a7db --- /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 0000000..d6ce290 --- /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 0000000..b229279 --- /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 0000000..b15ef97 --- /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 0000000..0b9488e --- /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 0000000..97b7a2e --- /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 0000000..78a8e2e --- /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 0000000..3c43668 --- /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 0000000..bd84af9 --- /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 0000000..9fd482f --- /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 0000000..62ccc91 --- /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 0000000..a5dd930 --- /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 0000000..535b135 --- /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 0000000..76cdf0b --- /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 0000000..dab973c --- /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 0000000..99738f9 --- /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 0000000..014b5ff --- /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 0000000..b3865e9 --- /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 0000000..a8497c2 --- /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 0000000..6e3da31 --- /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 0000000..121ca15 --- /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 0000000..f9dbfae --- /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 0000000..42e5d9b --- /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 0000000..0c0dcae --- /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 0000000..d5d441b --- /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 0000000..95b96db --- /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 0000000..11b4ba8 --- /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 0000000..6260142 --- /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 0000000..bc58fde --- /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 0000000..9430117 --- /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 0000000..edd700d --- /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 0000000..a1df668 --- /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 0000000..7474b5d --- /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 0000000..5677007 --- /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 0000000..776d35f --- /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 0000000..8df68db --- /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 0000000..6a44999 --- /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 0000000..6026900 --- /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 0000000..9026b01 --- /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 0000000..6b1e5c5 --- /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 0000000..d1e7f8f --- /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 0000000..ff6b7b7 --- /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 0000000..be848e3 --- /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 0000000..63c9562 --- /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 0000000..e22c76c --- /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 0000000..c356b3d --- /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 0000000..5797ce6 --- /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 0000000..4c42525 --- /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 0000000..2106005 --- /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 0000000..109f308 --- /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 0000000..d3edc71 --- /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 0000000..c3510b0 --- /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 0000000..e0674c0 --- /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 0000000..55abecf --- /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 0000000..8a9c56b --- /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 0000000..c57731b --- /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 0000000..bf5fb84 --- /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 0000000..89c5e0e --- /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 0000000..d01db12 --- /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 0000000..f576447 --- /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 0000000..1ca3a1d --- /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 0000000..9969326 --- /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 0000000..d2049de --- /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 0000000..277d58b --- /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 0000000..3cf858d --- /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 0000000..cd8fdcd --- /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 0000000..3b0aaa3 --- /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 0000000..1b4a4df --- /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 0000000..47ef574 --- /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 0000000..bf812a4 --- /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 0000000..c32feae --- /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 0000000..045b88b --- /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 0000000..d63c2c8 --- /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 0000000..6d2d99d --- /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 0000000..d667ce4 --- /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 0000000..1b95ab7 --- /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 0000000..fba4d10 --- /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 0000000..6e6f453 --- /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 0000000..6fa035a --- /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 0000000..40afc29 --- /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 0000000..5440156 --- /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 0000000..ebb90ec --- /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 0000000..346ce57 --- /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 0000000..f3ba6d7 --- /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 0000000..af18e90 --- /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 0000000..f81e794 --- /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 0000000..a7dfcad --- /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 0000000..9796c8c --- /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 0000000..5547d86 --- /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 0000000..8cd13b3 --- /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 0000000..6076bff --- /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 0000000..2fac020 --- /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 0000000..e970aa8 --- /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 0000000..71ae9fc --- /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 0000000..2b27b93 --- /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 0000000..add0c53 --- /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 0000000..2371175 --- /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 0000000..b14ba6a --- /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 0000000..4c9f25b --- /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 0000000..b82ec62 --- /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 0000000..09b473b --- /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 0000000..1b78858 --- /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 0000000..82e536c --- /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 0000000..15dc999 --- /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 0000000..5a04104 --- /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 0000000..1262b8c --- /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 0000000..0815715 --- /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 0000000..d0b8aea --- /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 0000000..d1b83d1 --- /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 0000000..1be6f0f --- /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 0000000..8b1999b --- /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 0000000..fab89cc --- /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 0000000..457b9e2 --- /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 0000000..6159aaf --- /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 0000000..e7eb428 --- /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 0000000..04ccfea --- /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 0000000..0a32d6c --- /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 0000000..11f2f62 --- /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 0000000..69ff2b4 --- /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 0000000..d85513b --- /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 0000000..dddc2eb --- /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 0000000..2013c59 --- /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 0000000..f4c2e02 --- /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 0000000..d45ff85 --- /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 0000000..7f2e43c --- /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 0000000..fb435f6 --- /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 0000000..2e35b82 --- /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 0000000..b67c0da --- /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 0000000..26e5bc6 --- /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 0000000..7f65638 --- /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 0000000..2cfc8f4 --- /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 0000000..26333f0 --- /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 0000000..4bd258f --- /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 0000000..45c102f --- /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 0000000..03447c3 --- /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 0000000..bf8302d --- /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 0000000..d4aacae --- /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 0000000..0bccce9 --- /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 0000000..1988d78 --- /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 0000000..6a37633 --- /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 0000000..b8ceb45 --- /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 0000000..055821f --- /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 0000000..99c0877 --- /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 0000000..ef4102f --- /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 0000000..29feb4c --- /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 0000000..dd25753 --- /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 0000000..0a0fdc5 --- /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 0000000..19c028a --- /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 0000000..de9026c --- /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 0000000..1ab0dba --- /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 0000000..dda9fce --- /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 0000000..778a953 --- /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 0000000..1be1848 --- /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 0000000..e1fbf86 --- /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 0000000..18e5bb1 --- /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 0000000..4e74c35 --- /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 0000000..2d6517a --- /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 0000000..a46a861 --- /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 0000000..30f32ba --- /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 0000000..0456ef0 --- /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 0000000..92f2879 --- /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 0000000..c33082f --- /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 0000000..2547b3e --- /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 0000000..0d61ab8 --- /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 0000000..bc7074b --- /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 0000000..502b692 --- /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 0000000..a78a685 --- /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 0000000..8f5dc0d --- /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 0000000..092b36f --- /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 0000000..2ad3eb2 --- /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 0000000..56d42b8 --- /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 0000000..9b92478 --- /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 0000000..81d8c39 --- /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 0000000..9a13899 --- /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 0000000..b8fe156 --- /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 0000000..3672bf8 --- /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 0000000..834d768 --- /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 0000000..f8da392 --- /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 0000000..af5668c --- /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 0000000..ca56c85 --- /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 0000000..730ade9 --- /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 0000000..2dd5b44 --- /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 0000000..ab09ba9 --- /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 0000000..5b36339 --- /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 0000000..15cdf4d --- /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 0000000..c2946f9 --- /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 0000000..fa16bfa --- /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 0000000..1824a10 --- /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 0000000..8046049 --- /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/85] 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 04e62fa..1509f44 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 5a00513..57860d7 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 579fba0..8575f89 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 8995f23..ab11878 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 0e87da3..8026f5b 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 68aa518..660e0d6 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 24acc9a..46d353f 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 7b29359..0275af5 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 2b8006c..241ec7a 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 40a7dd7..7ba631c 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 7014e7c..179e987 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 e5edb6f..9d525fc 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 60fdc9c..d14bcfd 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 319051f..6952916 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 2d3e8ed..1409340 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 e253d8a..6eddef1 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 cc3ff25..ecb0197 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 19f1600..65fe48c 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 e69b147..15b04a0 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 412aa01..2a174db 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 f02d7d8..5e3543d 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 f76dd7b..122943b 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 55c1aae..8dd6243 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 64f9288..222839a 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 5601dd3..716ff7f 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 e60f2e3..d505674 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 9997bf5..7f82eb6 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 88ccef4..e3db7c0 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 f72d12d..142b7eb 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 0922616..fd929a8 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 c26005a..b25cd2e 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 098b67e..d8eecbc 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 65f215d..bce2724 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 25501b1..2f0431c 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 c378c04..fc27a80 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 6f0aa4d..8ee106f 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 1a51b32..3170142 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 15c66a4..addac17 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 431af2a..bd540be 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 d869933..3ffea3b 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 ea29a5b..9e77c15 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 26694d1..ff52fe8 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 81da041..f768e42 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 8ba990c..cd8e7d5 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 4e87bc5..70106a6 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 fc5ef9c..b5d8121 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 eceb23a..8e7b5a9 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 e9b1e03..22264e9 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 0af3b9c..e082440 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 7ef7e3f..5817f28 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 6e83421..25a7319 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 5db7201..35fede3 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 245eb49..db4d6ba 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 afca905..e3f4ea7 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 6e15814..fff1315 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 005c7f0..1e7dc7e 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 bc438df..15c4c2b 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 7cb8288..cc9705d 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 d627f7f..b88de34 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 314b0e1..575ca9a 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 7ecc1c7..1f4e9c2 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 89c165b..9537600 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 7074f46..8675fc2 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 e150204..8783421 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 bbbdb73..fb7a182 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 77b055c..096ddde 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 922317d..a663294 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 a3ee70c..feff892 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 dff0d9c..aeed5c2 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 62885ee..b6ba3ad 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 61f7b89..62ed958 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 69d8b8f..324f4fc 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 80be3ae..8f3db19 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 e53a44c..b3d8f40 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 d1d6445..e7a6e5c 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 378633a..4174339 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 0e11a73..a6aed18 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 7348f75..5d451fe 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 c825d66..05618c1 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 b0ac284..1511055 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 ee6e9f0..ee7bf4a 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 9c15922..f8b6024 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 180da3b..30592d3 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 77e715a..12f844e 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 13042f2..9ea2440 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 ba5338b..6e5c84c 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 ea0b6b9..455d017 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 d91b35e..aa21f08 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 84e8dd4..656ea71 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 8530f41..68c2860 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 a959879..2787a0c 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 d4ad9f8..a4e180a 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 90ec1d0..6ff7498 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 42a88e0..80a64f5 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 b104fb9..9f33652 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 35f5cbe..523e421 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 766be0e..34eb4ae 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 fc9b0d4..b00c23f 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 7dc1569..0d6d34e 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 5bc5636..78e21ad 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 7280d5c..fb0cd7d 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 8260b85..92bbfea 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 ad31d4e..20c34e1 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 91ee546..e3daa32 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 c6fb795..ca30734 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 d198c4e..63c2816 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 af4440e..2279a79 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 493c12e..03fc720 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 5d015cc..f6c84ed 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 0fcb91d..9d48c3f 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 0dadf57..dcd160f 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 8495d34..6d75b7a 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 65cb9e3..1b98861 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 3155296..e84c445 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 3934bf4..d4d28bc 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 f736b7b..cf1c163 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 e9f412c..c5b55f8 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 1aa9299..39001e4 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 bfac549..74cb365 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 9c75dd4..19eb5f6 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 05d2a07..3b56a5b 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 2b01761..9524f2a 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 834d3bd..2ad93d6 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 c819ba2..8c9d34a 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 4164cd3..3ac21ff 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 7105f73..a36f5d6 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 d4eaed9..37d0717 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 a0dfc9f..ca38f83 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 3ffc983..a8871cf 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 fcfade6..e9964e8 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 8fcda99..0a354b1 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 e1acd2d..b58ef3b 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 5c61c2b..6885d2a 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 fa8715c..ac9aa9f 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 623ae0b..503bdd1 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 f15d5e2..579f4fe 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 5a09fc6..4ee87ce 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 2a74da9..9c181fe 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 5a7a271..e372fd7 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 89cd9de..c05dfea 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 1b55ce3..f66dedf 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 08292a4..66ebaed 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 07250c5..3f44560 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 7042398..892e502 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 a30d1ee..5dda85d 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 4d6ae32..f310efc 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 5c020ad..4cab84b 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 2b38715..4923c75 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 fd9f178..43f76ef 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 a4ff468..3286d9b 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 667d124..b11d4ef 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 a1604a5..8053d70 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 3b2baa5..95a8586 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 b18f895..cf6d8f1 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 fa398cc..b1a6681 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 7f1035c..13f4424 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 a39bb1f..1946824 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 6754771..a68ba99 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 e50c141..c418250 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 e6e441e..b4dd4cb 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 f96f4cf..54f1a95 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 a015894..0978e77 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 3a4beff..a0a3ec3 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 9cca324..5b1d75d 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 5f990c2..77f1458 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 804aced..a669838 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 722eff8..b856e79 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 6ab02ed..d5130ad 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 edad5e1..0ef0eab 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 3fbce89..b500e91 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 6d2245d..84e2819 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 144d262..3ce7f8e 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 9455a98..d7745a4 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 3c703c8..92bb1f4 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 290e988..cd404fc 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 fd00b13..374b8fe 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 07196fd..b12c037 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 b4d2802..8230743 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 7ae098b..c3db0a5 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 e3c950e..8f689c2 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 631b8e2..ed39703 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 8336281..2344251 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 7896c2a..6c2baf7 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 250405a..e9f265f 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 1a255cc..955c3ea 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 b871337..c4e7be9 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 a3536b6..83b95c9 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 c25b59e..49db002 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 fd6819e..ac0055c 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 e931d9f..67eb097 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 378ba78..5dd8c8f 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 f100e4b..d46882a 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 f8858f0..e243973 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 9148229..9a65acf 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 23a37da..0bd927c 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 7a2c6f5..beeea7e 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 eae584e..b082b5a 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 5aaeb25..b5be092 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 40598c6..d19d0d7 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 c2327c1..fe14736 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 b033ed6..a4863b8 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 a5a8740..852683c 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 0fc415b..3623a07 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 1b61c14..2d9c3b3 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 bd91a9f..313d0a1 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 eafb81b..6c5c6e1 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 cd3a6c2..3545f4c 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 4c2ac39..ee32523 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 2b049a4..420a81c 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 10d52fd..cc0dc8a 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 907ed97..2f3982a 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 9766fc4..8a0ad5c 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 5d49761..6ad7094 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 2732e1b..a5b3b2b 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 1622d69..c704df8 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 78ed463..8e65038 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 313551a..1c8637d 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 d76d4c9..3c53b2d 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 6f007e2..a4ab9ec 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 44df948..8fcc142 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 a82638d..bda2064 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 89ecace..bf4770a 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 740485d..ede7915 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 b2556ab..aaa00c9 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 e71e46d..a244569 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 ac3a028..c714e60 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 685ac54..d2603c2 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 ec15210..5921bfb 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 8f0e42f..b98a7bb 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 d69315a..21f2d1c 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 c388270..ebb178c 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 c1740c9..047ce0b 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 4083788..1446d79 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 7fca6ae..4080e49 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 164f5b8..0b53126 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 ecd417a..744081b 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 2ba94ef..845f915 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 321d663..52a28e2 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 0d9a20a..6c58111 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 82b0265..021432e 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 7a8f704..673c1be 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 1208918..4077745 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 8612eb9..71bbf3d 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 dc21a92..ac59e14 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 6cc3351..7a2bd11 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 0d82246..1fe0eb4 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 c11b991..15a7e23 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 1e53149..ce57bfd 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 a7ebad2..d6dd987 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 6cea364..b06ff32 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 c362dc9..3b3e241 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 4a17d9a..329a42f 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 eca1ffa..b46ba69 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 223d09a..8e2ce25 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 5d1d04c..5106304 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 b2d56c2..6e6f58f 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 e76ff3e..b5882ac 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 8241f4e..d545699 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 d58fcd9..18d3da4 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 65543c8..a543925 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 5ef376e..1064813 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 7c97623..9a6a772 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 f8d6b7f..95578ca 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 8c858da..db4a7f8 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 973f27a..e706b43 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 e2b2494..f3924fe 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 b605532..021531c 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 8b80a9b..9496b5a 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 b456034..50610e8 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 d0d5e7f..9c3f2ff 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 120db9c..dfcd574 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 99ed7b2..2701ed3 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 0ed2fda..92ddae6 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 a16300c..8d22092 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 c196337..fd72aac 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 91caa12..e9ee24e 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 a2c7a05..d212464 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 fd8cca4..8a0b4e6 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 b2a3fe7..dfaa571 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 1e6d9d8..82b40ec 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 7fcfeff..8b91638 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 beff337..36560fb 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 e8c63da..b6006fa 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 2b4b7a5..05f2b35 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 493f66a..eccbfb4 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 500b726..00c3e82 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 e6dd9b3..27e10f0 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 4fbd319..032ab01 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 6628ccf..8c27ddb 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 7b7b6cb..9058f16 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 7713e43..c790ac2 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 be812bd..3b27ce7 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 995fea9..0072595 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 c63ff4d..db2c209 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 134982a..d91877d 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 3fed504..94a9c34 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 413f2b1..5c1f0c8 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 9a51f64..008d1de 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 50b5624..185e058 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 3166fdd..93e2036 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 0fc1653..788a8ca 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 6de9a6d..6714f4f 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 8083916..afb4bbd 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 d9171bc..9648203 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 740bfcd..1e22c86 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 26587ac..855feaa 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 2df1f29..5644dc1 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 2031d39..e0b6b0a 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 691e14c..22c6f0f 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 2b117a3..d97f7e6 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 ee1a8ef..9d60e5e 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 40da97c..bb90c1a 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 1bab8d1..1e9e25d 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 92b375a..c4155ce 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 15e72e1..50b2532 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 8dbc8ff..7ab2565 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 5a89400..e41c7c3 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 64841d0..6ce6d63 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 bf870f3..fa4c880 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 bb6186c..06caa68 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 9ccb8bb..1d31584 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 c220cb3..69627ee 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 edfdbed..fb6a545 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 1206a30..ae25a9f 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 b6b4b81..968d669 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 2582a72..d615388 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 dad29c2..b340770 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 8a845a7..775b0d5 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 a6430c7..766ac4e 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 b637988..58fe22e 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 eea4d32..110f213 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 79e606c..4bebf08 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 746b2dd..0975335 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 0992779..13a6db6 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 0c0437e..b0f634a 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 c45d106..1681221 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 e9d3f72..71b89c1 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 b76efe4..2ca18b4 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 ec50aa0..03996c2 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 57f6ec4..d8b4823 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 7aa068c..bc747ca 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 7297407..c5da28f 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 6b9f671..b6bd43d 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 985b664..403c1cc 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 8692ce8..fd64adc 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 7331443..fe4550f 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 41b83ba..818a3c1 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 feadbbb..1ce4f8e 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 b3d5552..cd6b76d 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 e484e85..a48c1c1 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 e34462e..4e5e2bc 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 91d6266..44a8391 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 1b78d29..99b8d1a 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 58d543f..d4a8a0a 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 dc78e2e..8d2617e 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 f9ddbfe..4eea0c3 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 b6adea0..f39a4b8 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 e9f4d62..4595e8d 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 469bc2f..9519c80 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 941770e..607fde4 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 21ef474..0d26c33 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 2666bf1..439e9ec 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 94bc808..584d12b 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 4d4e229..b6894c0 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 1e6b6ed..afe2231 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 145f988..d7d2faf 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 b4fcf8e..bb4c169 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 54ae928..c98d8e4 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 f60e49b..dfd5f78 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 ba041a4..22252d5 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 1bb8dad..4d61560 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 e6f3a4d..1c8c918 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 87107d2..9c7fc71 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 8c018a5..866da14 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 5e573f7..4d9154d 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 11902e6..f0b2926 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 1ad8c26..c11c238 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 fcc5636..185c124 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 46751f4..4789586 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 34d6784..3727308 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 f6d07db..8f0c4a4 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 98778eb..943f082 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 e7c49db..969880d 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 4ec9eff..271d70b 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 a880836..c8b91bf 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 80b4b59..c19c0bf 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 b160709..15dd2b3 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 8be0de2..952cc84 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 cd94c7a..e5126ad 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 a59f521..a4b87ca 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 75aa30a..0422761 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 2a575a0..e619088 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 9439373..2e8b382 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 fe1d5a7..a766744 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 6f605ba..0cac30c 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 cf9e67e..c120f7d 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 94cdcfd..b307bc2 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 b3b77ec..adf2ffd 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 bb50b80..2e8972f 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 91a16bd..e7411b6 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 7ca5a9a..180e57e 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 5d65b31..6cf6091 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 521c047..d74106a 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 0de62a3..d891dbd 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 22d57b8..2c743ab 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 3ed551a..74cd8de 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 58e6e43..9dba29e 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 23cd2c7..6c449cc 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 b460c8d..05c28a1 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 d275eed..a29c469 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 fcefd8e..48ac0e5 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 cc47e99..426192a 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 269f6aa..a8f35e6 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 e06a115..00cee50 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 3e13533..13d694b 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 e1837d0..c2c9998 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 b4fc005..d9b8204 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 618515d..f4aef2d 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 bd3bffc..336be04 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 21d80bd..fbdf72a 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 b7b23d5..5623c1f 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 445f77f..1cf9e43 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 d025d7c..d48dd8c 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 9ed6b6f..d1e19a9 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 68c8c71..1389fbe 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 fbc9b9f..2d7af17 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 5679e7e..dfac2ea 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 66c3561..01f2e87 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 66b3a92..da6868d 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 bd858d0..b3c7a3b 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 fdd1ac5..9cdc9f3 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 e3ab7cd..1e9ec14 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 2282b1a..b17b829 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 9ad2eff..7a89e1c 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 b0db2eb..02dd8fa 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 a56aff0..d30cf2c 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 05fc664..2e7e989 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 de76e7c..1c5b679 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 198150e..4276a25 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 cf30c44..f784f66 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 2cecf5c..99f70a5 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 3f7d964..0ac4e56 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 6f6ee78..d96849c 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 c43e4aa..842832d 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 073fd1f..1f31e09 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 d692760..f5d6066 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 3495742..d4e0150 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 06792a0..e6284d0 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 e0ee9de..55d0c94 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 a45d71e..dd14ff2 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 b22c328..5c97ec6 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 61b13a9..fe2000d 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 2826765..d1b6a95 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 d3f8341..875ed9c 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 e142890..4d0e7a0 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 b401eef..ae2baaf 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 e0c18a5..61ff1e0 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 4b2fa23..5a4e4ef 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 86762ad..c75f03a 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 ac98566..1cdea93 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 448e56c..f967a12 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 f366e82..709cdf0 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 b63f083..aa0b6e1 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 d1f5440..9a4ac72 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 fc84c7f..b98f9a2 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 75f9b06..a389b91 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 195b6d6..adba841 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 a82c66f..c36007a 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 08a81ef..5a0532b 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 f6ec5f0..553b6d5 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 bf5bd4e..91bef63 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 a55cbee..c9b6d6d 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 cdfbc27..0613a9f 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 cc09959..9d3ab0a 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 de88043..eca7cca 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 d4c561e..fef2b79 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 15698a1..d24bfdc 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 70b87f9..4811f00 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 ac04f35..a8d5df6 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 98d60bf..ebed22f 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 e25ee33..91e4150 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 36924a6..5600404 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 ea4e512..143848f 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 c85e35a..896e55b 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 4e14b00..8fb7bd5 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 931bf5e..cb6cb82 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 675c311..59acab4 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 749019e..9c8ad82 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 704395a..bf19545 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 0cd9a33..aae3f0d 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 1a5cae6..2f60ffd 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 9955821..a75d3f9 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 b370ea7..a045abc 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 307be3c..51a85d0 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 e04b791..b8c8cb9 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 c7515cb..aeeffd2 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 57377b0..bb6c566 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 1db0184..a9b4a87 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 f003992..29a496b 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 f253db7..5b31f0d 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 ca8a482..98222e7 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 5152813..92b2c06 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 2059f0e..2a4e5ed 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 a8991c2..c828274 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 8a8bb51..ccaae25 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 dbd1ac2..fb106d8 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 c95bf39..3f22b3a 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 6967351..bc60afa 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 dd96a06..387f135 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 6c6f7ec..e2fc16c 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 aa1c02f..93dd31c 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 689fdf3..fa9dbc6 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 5f7507d..cef3c23 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 fb9c8b8..9990c37 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 70c6dc1..e7f2577 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 ba3ec88..9406912 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 5aa77ab..4e938d4 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 164b176..00c3ebf 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 9175252..b45bd9a 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 fccf5a6..8c0c91d 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 f03186c..7e4d648 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 316c4d1..3c4adfe 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 0801b59..fdf5bbd 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 20ebddd..2dd5353 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 8130e1f..ee9d5fc 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 c5a91e1..f372076 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 4541148..9985a93 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 f433771..1bbcb17 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 3791c67..594cee4 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 51d5cbe..bb8c6aa 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 93d06f6..664f34e 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 e644046..0664b4c 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 4d0492f..702813e 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 d8d6db1..e02e41d 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 a9b303b..69e33c1 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 55228ff..16980a0 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 be8172a..95679e4 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 fbdbef7..3a091ab 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 8ef71f9..b13d834 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 0554cbe..cb38278 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 7f788c3..ff121da 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 f311889..a6f2654 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 1e13fe4..6b1ce7e 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 95f343c..a6dbaf7 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 dfaa231..14104c0 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 8652f17..4fa2df0 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 eb6e2c2..4037966 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 5c50e0d..91a2ee6 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 2cbe65c..b24702d 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 1ba12c5..ab2d653 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 6da3b3f..4b6cbd2 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 06d32ec..ee595c9 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 f397f9f..c2fc8fb 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 2877e3a..bcd6216 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 cf45794..90b5463 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 ce5a3e4..a47bf2d 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 4703754..948b429 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 bf57425..10a076f 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 a9d9499..48bed45 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 cf93c09..8f2a5d2 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 f5e2301..e1be141 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 404c38d..6ecc486 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 c6af728..19d6186 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 844ff64..14eaeaf 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 23187dd..af0247a 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 4f8e3f4..8e5badd 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 c2f2078..966d2c4 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 ce486ba..60ec96b 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 c388075..7e51779 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 520ab9a..1c64db0 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 4d65547..da43b0f 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 ed11009..cf725ce 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 10f0507..fdbd16b 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 b2604e5..dbe9872 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 5d8d10a..476394b 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 fdc17fd..31e9766 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 a0adce1..f32a3d7 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 7cfb35e..840564a 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 05d7df1..9bb06c4 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 b465106..efb1b0d 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 a330a5a..57f1039 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 328d987..8690f73 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 59e5f73..df53246 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 0611196..59434ae 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 b7405d2..b63eb9f 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 994c35b..2708923 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 e1a4876..109f32b 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 bbe128b..03f528b 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 2160f6e..7763aa7 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 ed86ca4..70f94cf 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 dcf10d8..2ee8baf 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 96c70fd..cb70c9d 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 44c0dae..2d59a41 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 1a41a22..e3ebaac 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 e8cae48..1402327 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 4dcd64d..6cdf410 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 57f4ec5..5a23869 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 17b0d82..a1ddfe9 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 5d9c4b1..60e39d6 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 cb6d86d..330958a 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 8487b3c..7157017 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 0030e23..10fe362 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 35a4331..387487a 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 633806f..370b603 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 45be393..115bd4b 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 ec50942..2215f5b 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 165236b..ecdee21 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 de150f2..ad884ab 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 6201b51..79545a5 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 89818f6..aef1b22 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 32f5aa2..6228706 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 7341b71..324d303 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 ff8305a..89da981 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 f062980..4fdc919 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 ee212a0..367b1c9 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 a7b9d24..213b596 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 0fabbe8..4526d10 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 a2ba42b..6c84e3e 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 1cdb745..84955b9 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 3c82ee0..ae02028 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 1d2c98b..8909a26 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 1018a6d..097b5a1 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 8e68d24..74718f2 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 b5ce34d..31fb0f7 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 939303f..a48d4e9 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 5096dc1..2c2a87a 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 16bc41d..113bb90 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 e104a60..1668736 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 9243b2a..1b9d0f4 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 2daa9f9..2a10f3b 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 1fd6494..9868647 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 5f9e626..03a46ec 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 3b6b231..610e727 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 c51a978..877e2b1 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 8bb52c8..a2e3f5c 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 c0f1dc1..418b583 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 a43e069..4c9fb59 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 257e6a1..5ad9501 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 4f851da..a373eab 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 4ceec17..a3a5006 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 8daa629..ab25d7f 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 baf541e..c45c35f 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 83095a6..dc85cf2 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 681396b..590613b 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 29ff4bc..a8bc397 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 1eecd03..f3eb939 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 b8f158e..139de34 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 db9f6f0..3b136b9 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 d445912..d917ae0 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 c044bfb..1f2b462 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 b3de4b3..3bd55d7 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 0128158..595baa6 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 3494571..14a14f6 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 acaf48d..935c357 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 64cc926..4efd73c 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 b38c7b4..39e03a8 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 1096a00..4ca6047 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 061b0cd..73b8250 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 2888ee4..520a888 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 07c2a8d..8e0e142 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 6386ac8..d4c373b 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 0cc6e35..78c3c81 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 bcd5e20..a182371 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 1f04eee..13002e0 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 88710e7..b11c1d4 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 06d1b17..3568f00 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 ef48555..4016c43 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 05e4823..5cbde78 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 5151147..e9a7b18 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 16680ec..673b709 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 0fdfdf0..27100f8 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 997a423..b4ad533 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 ea5b2a3..1a6d65e 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 146b18a..2788e86 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 4629bb2..a7b2069 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 3650247..bffff53 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 57ec0d8..4be0628 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 902a427..360aa1f 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 37a4fa6..d13d719 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 3ab67a8..4dcf2d6 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 f91a275..8b3ad8d 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 f1f380e..f3dfb9b 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 f46e7f5..4dfe58e 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 ce8c2d8..705d79d 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 035115a..864ae25 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 7c80b67..2fef7d4 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 ad898b4..722d610 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 2600d39..f8110e1 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 f2b8725..c0c4ee6 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 a747895..c94f209 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 e677214..e1dfa6d 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 bdf53f6..2991a6a 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 0158805..a965012 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 f6ea5ac..52716ca 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 d7ffda1..9abf1eb 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 4f60232..d247f36 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 0284d6e..e07b6fc 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 41d3ec2..48c30d9 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 abe12a2..842bc6c 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 e77f3f9..34e5624 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 db47e8f..8a70c1e 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 38d79ad..f5adf61 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 5902f72..4c2ec9b 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 961422e..7824fa5 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 f0940cb..7bc4ad9 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 64b2c30..166640c 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 b89c63a..bc896f0 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 9cce318..959afab 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 7eee1af..7109d19 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 835d2a8..002a1fd 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 3ac50a1..b34baf5 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 6af171c..57729f6 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 e6ff36b..24d1ccc 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 ae40572..1948de0 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 fd9e0fb..ecfbe40 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 0b99164..d69be67 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 4831e2d..9c52297 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 0d4e1f8..2ffaadf 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 853f639..39cb069 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 5852412..9a0a012 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 0b8f91e..d31da56 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 55d9d61..352e297 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 ba41a1e..abf1c22 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 3af2894..531be9e 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 4b00af5..bad3a35 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 f89764b..3a3bfff 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 55064df..9b74b44 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 ec10d31..e6c820f 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 ee853e6..926f1bb 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 17aa323..cf69d92 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 e2bc748..ff490b2 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 2f5b957..a67387a 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 7071a39..021a346 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 92608dd..2c2c2c6 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 bc1fcfc..912a078 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 60ce5c9..36ce72b 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 8dcc978..17ef4f0 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 7042ce7..b70a94f 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 15c36b2..144807e 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 ffb8f9f..9f783e5 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 3c6c040..9f9eb1f 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 2504eeb..058b5e1 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 25ba0b7..f1e0443 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 0b9f718..98497c0 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 74d6dff..f604dc1 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 1d73241..5014369 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 f9b9bef..95c76a6 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 1314ddf..8a112bb 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 2b13d91..05c7b78 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 68512ee..3223325 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 b3c5287..babf827 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 3fe9ae9..1bfcec3 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 f08ed05..38f0a29 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 69487e2..c495060 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 7b9132b..5f2754f 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 1b234bc..2bc552b 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 3a823a8..6b4a754 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 823bea1..3a6a68b 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 f887f27..683f033 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 9e8e6ff..f3df1a6 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 018dc61..a771196 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 4d0d725..51693a8 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 b8ec2c5..b79e4ab 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 c53af66..bdbdf42 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 3e54601..22f9ece 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 749c618..290bf26 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 b10e08f..b57d128 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 5afea30..5798a11 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 334d036..8806833 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 f9420cd..7bb22cb 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 d03b2a5..9b2fbe7 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 f36aded..d1c339e 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 4beabce..8941075 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 b1ff03e..c221ba8 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 fe5c284..643fbc5 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 8f96c0b..98c0f61 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 791ede6..1344805 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 5dd59da..3a3f73b 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 d327e7b..063f8f9 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 1c63743..e9c6f95 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 7cc0766..5eca79e 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 c607c29..b694675 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 eddf8d9..456ed8e 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 b241129..510527a 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 bdec582..aeffe52 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 d2802dd..7fd3b9a 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 84960a0..1d66f24 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 e53ad8b..a082af3 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 2070791..bfa7f5b 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 3fd1cf8..8487610 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 e218c00..8229f21 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 ed59012..9ba6f9b 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 093968a..33cda47 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 45fc82e..0134d64 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 48918ca..17041b7 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 faacd5c..0d2b069 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 1c75b92..095fb84 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 7332eb8..99fd886 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 767f845..8c75785 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 12963e3..35c4bcd 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 9b808c2..07d875a 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 e6ea401..8df30bf 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 d2a2f93..bc4d468 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 d48cf5d..3959cbb 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 48894cb..604ecb9 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 63ca28c..b132e5b 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 1f194d9..2cf35a0 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 7731c26..cf8390d 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 3390a42..466450a 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 8469d8c..1b89460 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 6ad8524..31fac08 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 60d58b6..675a29f 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 455018d..8222026 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 f08a1b3..9f64bd4 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 1cce363..cd23705 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 e89454e..c277b18 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 68ddd43..1c60e72 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 863c4c6..387bbe1 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 b9c0c2e..e381496 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 bbbdb91..bbf05df 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 cd22b71..8275660 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 0330630..e883ae1 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 7f74bec..223a41c 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 7631216..1928c4d 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 dbe75c9..4662221 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 f6eb00b..ee38745 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 a084760..2440fb3 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 1565adb..ef459de 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 78c6762..3a6ec19 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 c37177a..bc6eb46 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 e754175..a1dd342 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 c37a287..c1c7be3 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 ea16672..4a3c16b 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 44e1eb6..6932201 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 42311f5..8c0a2b3 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 26fcfe8..fa02c93 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 d6a70e0..fbc1756 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 5e1ab17..200528e 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 22c762e..edaeb90 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 9beb5db..ada9f40 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 deb5073..c36f5d1 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 454c112..11b1233 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 3dbb6ea..3654de5 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 404c9fe..6b269bf 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 4fbcf4e..f73a09c 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 156b2d0..fe31211 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 945394c..639fa39 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 202518e..81b32b9 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 f68808b..16f0d9b 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 f8e64f6..d86ebcc 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 e3cdb3e..d40e624 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 d55708b..1258b86 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 6288454..0693424 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 a78f98a..84d3174 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 2cab666..4287349 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 3d0f49e..4b4a925 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 93eb4ad..a8c6316 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 5595322..f25a28d 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 b16c718..68d293f 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 2d9710c..69d2cb9 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 5e4af54..c031ff1 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 e760567..5f09bd2 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 e8b34e9..3e8160a 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 4a66f5e..f802420 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 51cf39d..bcaf40f 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 d989bdd..b1cf4f2 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 3f54374..753ec8c 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 c28e086..27b0940 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 8cbf370..ef98614 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 c371663..118fd31 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 4d94ed8..e6f35db 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 f3a2bf2..fd4d430 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 6d383a1..429f000 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 9063ee6..0691505 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 236f2e5..0f2c1a2 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 f161099..582f15b 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 564fa6d..a9a0a53 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 c822489..c298d6e 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 9bf0976..2122aaf 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 88d8620..36c3404 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 13465eb..ee9d3a7 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 0ef7056..86a04c0 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 65c382d..8e6e168 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 aff35e4..3a9994b 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 704c6c7..b87b7ff 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 3e3cf41..81c0ab5 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 b4401eb..aed0b90 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 34ce038..2958993 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 ba49d03..31a02e9 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 5184319..4860d0f 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 4366303..8672c15 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 f8a9381..4af5766 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 eee6352..1609896 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 ee3aab5..e4e784e 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 aa57c33..4b12a0d 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 138e700..d5a3fb9 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 cea732d..945ae40 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 b04c279..b5667f5 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 a3e946b..60b0c37 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 3250c2f..01eabde 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 3c95c44..ddf4e92 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 516c330..6ef857e 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 ef4ff1d..245f2f0 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 c35bd5b..662bcd8 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 d662e93..7e92c08 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 beed9eb..d81ee67 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 9da7f67..2844522 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 162b171..ce8abdb 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 5673096..f7e0caa 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 c2d5577..2e3f9a5 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 b276cb4..3a2cf55 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 c993903..c69e2a5 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 3172819..33929a0 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 e7ca1a5..476870f 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 d110220..afba779 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 507110a..a93b875 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 c3617a0..a99c2c0 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 b9b9530..7799721 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 2ec20cb..4e804a3 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 ca2e097..e103d7d 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 92c905a..ed9465c 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 87ff872..e40bd7c 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 b3d9eb2..355b1b2 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 45e3472..95ea604 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 471c4ba..eeea0a8 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 65879a5..9607189 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 f1a064c..4cb0a68 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 b3e2fb2..f1aa579 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 82732e2..64ad6c0 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 6dace85..bec32c9 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 fecec21..4172819 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 7d1c8d7..99cef96 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 0aa17e0..adaff35 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 d1a817c..8f7d209 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 f3b764e..03b3d35 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 8b9cea2..6569d00 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 1060ef8..aff5bca 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 276161d..8e7abd9 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 639f605..b58669a 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 80ab689..2d65ebd 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 563882d..902107b 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 9d19eeb..aba9285 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 d567aca..5cff114 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 a338548..1ef8c0a 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 4763ea6..db14872 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 f8b9f2b..ad99d47 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 3119d04..02ea303 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 b8f464b..096df48 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 3597e55..585dd31 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 bdeb731..aae55b0 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 790474b..8b870ac 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 55047be..f80d3fb 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 174909a..27b020e 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 141fe48..14ae9b6 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 6fd95bd..b99358f 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 f747a1f..5248ebd 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 7129333..5a824bb 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 a49c737..13c6a46 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 8866aa4..5c07c8a 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 4afc378..47012f1 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 d2f40ed..c1f705b 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 c8872d0..9a84e0f 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 2ff19a3..a785f02 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 016e08d..74722f8 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 12f09bc..d4792b5 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 9674ddc..4c9997e 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 35a0414..c1f4aa4 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 ae28fbb..912aa69 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 7d46d90..18339e4 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 fe17387..b9c88b0 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 938dc78..0b83e27 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 c1dadf6..941da95 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 a433427..01397f0 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 ddfb52a..660fdf9 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 596eb85..fd1b672 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 59abebf..b5e5897 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 f6f297a..f6dbd2d 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 4d559bf..8eae521 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 71352d9..1237d41 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 5734f28..1fb7da2 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 e8b122f..6974668 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 309efa8..a57ca6a 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 b96bc5c..5b8e37a 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 26a0d25..747c8e3 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 0a6520f..0c42a52 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 108bb45..3d73e5c 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 6639bde..fb7d89f 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 e234f34..de495fb 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 073a0bc..5f8f7c9 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 18d2763..89921f3 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 28ef0f0..b9c59f1 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 106a258..6b966c1 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 0257f78..3c5381c 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 551c9c5..3cef5d9 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 1c4d235..973a288 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 a75238f..6a4fe60 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 b771286..54e51db 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 2792127..e234659 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 9671768..7620237 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 d88dbe3..d49f5b1 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 857a90b..a073096 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 64d7571..3bcb6e7 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 03428a7..858245e 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 3a21bbb..d7e6daf 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 fbab976..7692172 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 719a508..c4346cf 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 a314556..49a9e75 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 eb788cf..6dd0207 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 18fb782..8da3fd5 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 485f3a1..43c7330 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 ac4c343..be0750d 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 dee9f24..215a4cc 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 30974f7..499ecee 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 c1acccb..a632b47 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 1946ef7..659c49a 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 e7817e7..bd750a4 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 b2be605..0a05f88 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 bacb5c0..2a0ce84 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 4142661..7df5a90 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 ba99dbc..7b1dfc1 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 d9c7b8d..c1f8705 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 4391066..befe889 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 9df49d5..a6e5b4a 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 fb73032..d5fed20 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 9dc257a..eae41d7 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 77d5ddb..2ebb9f5 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 7decf8d..0980d39 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 a910a9a..04177bd 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 1640988..7faa679 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 bd2ab0a..ac007b3 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 3be5f74..1223f19 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 f3323a8..d667672 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 2a7ce5e..d6405ac 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 fb7e7ea..e0a9255 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 34ce71a..1da68db 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 3751aab..9793843 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 f9de433..b721f9a 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 a951075..0e55e24 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 cac872a..e772572 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 a130569..4724598 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 58a634d..89a9c9b 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 db46242..f842237 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 faa55bf..763d5dc 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 d45d075..40bbe83 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 83470ca..c3e9023 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 1235f39..ad88eca 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 8157a66..a11a8ea 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 c349bb8..3d4a6e9 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 70ff43e..9d8ab5f 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 c737f8c..ed9accb 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 45b888b..f0d4bc3 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 ef9e54d..fcefb45 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 df61026..a83263f 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 419ae72..cf7d073 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 2f27027..061205a 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 39776a8..c34eb2d 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 8a6b4c7..e62b54b 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 07d9038..303207b 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 1512fbf..36c0038 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 7595546..5c59e26 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 285f36c..63f07f4 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 38883eb..09e6b0c 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 9e320af..3bf553f 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 c9198d6..20086b1 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 1697fcf..531b54e 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 e89ed08..9e1d3fa 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 40b4ab0..2fd552d 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 295f43b..c238253 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 abe7b8f..2123022 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 d2ae292..6b6b2ea 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 5d5d3c8..39ed0fb 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 33eb074..e9aa6ea 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 684e3af..6cfbc5a 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 6a8a090..b904bd0 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 d64bcb9..ee8c04f 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 79198ab..5f597d6 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 95a4098..bb1feea 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 61c4a2e..79c211b 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 98674b6..552b459 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 c705db7..a1a1eda 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 4ad1f4c..b7a2074 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 01b94f7..d96a865 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 d8e4fde..68c2c4e 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 378ad2c..b613d67 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 24bc361..88385fc 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 1865d49..df0b01a 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 9a6287a..2c0618c 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 2855560..35c5491 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 90db6ba..86e0461 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 240e8fa..0059789 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 8231b83..543c19c 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 22d1322..79e9c95 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 b4fb30f..e610a1e 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 328b7f4..538d9bc 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 7888a82..4a55d68 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 0c3255e..122b7ea 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 1e6798e..d0b628f 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 44f6ff5..0fd50fd 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 006e531..4757c76 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 b1730e0..25b0b07 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 5c62fba..6348efb 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 08b21c5..f7e501e 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 c455e3e..26e3bdd 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 2e3cc5c..5a979a5 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 d5faa53..598947b 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 00e9f6d..79898cc 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 25df8c9..3e0133f 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 8c0dcde..d89d1f6 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 973ac7b..f092c7a 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 aeb55e5..29c4903 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 804db66..8b62084 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 0b0f670..3dcbb18 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 87bf3b4..31acbe8 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 b01dab6..d56ca88 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 3b05265..65a721d 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 3f06311..c7b6c2c 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 b141aa4..855e75d 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 73ffee6..6898537 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 218fec8..1635c76 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 5195972..9a1cb3f 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 f6b114e..36f4073 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 9a71c8d..935c283 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 479eb2f..670d934 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 4dc5747..47af0c2 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 7ed7885..641e202 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 729fbd9..4270592 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 389919b..bedb28d 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 e01316d..4283f78 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 2a658d8..162d24e 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 1f39e0c..16852de 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 893d43f..5765585 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 ec6e004..6b306ba 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 91069cc..1eb222d 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 5a20088..10c5551 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 b9060ce..565538e 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 3c70857..a8b4bc8 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 d7bcee3..0664e36 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 364877d..1ce474d 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 b64dd32..c8ea61d 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 f858358..ea3ff51 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 f1ddd7b..a0ee8b3 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 141142b..93ac61c 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 c211ef3..c47604d 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 6f1e59a..5da445a 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 17de885..097c58f 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 6f43a62..e4d78d1 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 2202f0b..5b9bdb8 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 be49515..46728b6 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 3d83b55..aaf4f16 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 b70fe28..453d4a8 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 dc6118f..8d421b3 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 2b1b3b2..aeb7589 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 62a3f27..44c82f2 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 efb2fca..14325ef 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 b76a99e..250d3dd 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 926ba01..66ac3d5 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 87161fe..a6615c9 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 9f7198f..c1ffbe3 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 77a59d2..04e0859 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 9dbef33..6c0e228 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 70a196d..b10ef12 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 22f9f1a..a3aceae 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 5a3b390..0ebbb00 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 bd80c9d..de2c12c 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 4fc8da1..73a09da 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 caf1676..389246f 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 802bc70..f2e500d 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 9635e0c..e7e1fe4 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 5fefa74..51debbd 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 a08a33d..4cb902b 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 65be4f5..220df48 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 5164fe6..0962f84 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 cf3a7db..07ddf7c 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 d6ce290..a583d66 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 b229279..36f61ff 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 b15ef97..aaa7af1 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 0b9488e..2865251 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 97b7a2e..9fc5f77 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 78a8e2e..445bf36 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 3c43668..dfaeb62 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 bd84af9..0e5c5ac 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 9fd482f..823ba6a 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 62ccc91..869b7cb 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 a5dd930..f908e9d 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 76cdf0b..e17c900 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 dab973c..938b3b7 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 99738f9..04a4ddf 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 014b5ff..e8db331 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 b3865e9..0157658 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 a8497c2..f40bcb4 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 6e3da31..657c201 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 121ca15..fd2a426 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 f9dbfae..5e9f908 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 42e5d9b..7138e18 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 0c0dcae..66a0b24 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 d5d441b..b0e3fea 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 95b96db..cd36b1f 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 11b4ba8..629c9f4 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 6260142..fd54157 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 bc58fde..9bb0693 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 9430117..9c1f358 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 edd700d..a5ba976 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 a1df668..7dd0cf1 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 7474b5d..21bdd84 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 5677007..1fd3458 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 776d35f..c808a37 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 8df68db..d46b09d 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 6a44999..050cc2f 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 6026900..9a21e29 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 9026b01..04a523c 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 6b1e5c5..cd5e08f 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 d1e7f8f..1d7ca14 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 ff6b7b7..b3b966f 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 be848e3..e7daad8 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 63c9562..1ec60b8 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 e22c76c..1457178 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 c356b3d..b09a188 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 5797ce6..8451ded 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 4c42525..b3c4155 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 2106005..859764f 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 109f308..de7ff95 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 d3edc71..6be6d65 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 c3510b0..396ed93 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 e0674c0..8629081 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 55abecf..fe8128e 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 8a9c56b..69e4f19 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 c57731b..9ec2127 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 bf5fb84..07f064b 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 89c5e0e..1a82eba 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 d01db12..a3c59f2 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 f576447..8d28793 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 9969326..d1853d9 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 d2049de..0bed127 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 277d58b..250bfe3 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 3cf858d..989a560 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 cd8fdcd..54f410f 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 3b0aaa3..2bf11b6 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 1b4a4df..14a2f11 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 47ef574..4dce41a 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 bf812a4..9e06f67 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 c32feae..edf2ffc 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 045b88b..3854d86 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 d63c2c8..bea2c25 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 6d2d99d..c7e49d7 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 d667ce4..3690fb9 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 1b95ab7..f5368ac 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 fba4d10..a63cc1a 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 6e6f453..5c8cb06 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 6fa035a..52c29de 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 40afc29..68f57d8 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 5440156..82a6510 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 ebb90ec..2c9394f 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 346ce57..9081a30 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 f3ba6d7..2fb4865 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 af18e90..eca5ac7 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 f81e794..1fb8aac 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 a7dfcad..a5592df 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 9796c8c..abbfaea 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 5547d86..9864f79 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 8cd13b3..ed29c8b 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 6076bff..2399a41 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 2fac020..ce5fb94 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 e970aa8..fc99fa9 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 71ae9fc..467816c 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 2b27b93..a13cafe 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 add0c53..1d171eb 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 2371175..1398517 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 b14ba6a..8b37cf6 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 4c9f25b..21b1d8d 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 b82ec62..e7da22d 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 09b473b..a37b146 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 1b78858..1b68ad4 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 82e536c..6c11513 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 15dc999..991f05f 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 5a04104..a6b70a6 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 1262b8c..297d6c7 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 0815715..01a0ba0 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 d0b8aea..3db574a 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 d1b83d1..772a1c0 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 1be6f0f..25a8de5 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 8b1999b..77eafe7 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 fab89cc..b0d13a7 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 457b9e2..61296bb 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 6159aaf..fd91a2b 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 04ccfea..f0f9024 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 0a32d6c..e048ba5 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 11f2f62..c23f259 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 69ff2b4..0fb5cf5 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 d85513b..a04453c 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 dddc2eb..dd4211e 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 2013c59..e9e09c2 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 f4c2e02..e757d83 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 d45ff85..ee8777a 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 7f2e43c..4509bc9 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 fb435f6..8133063 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 2e35b82..58c43a3 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 b67c0da..827c294 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 26e5bc6..7e90491 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 7f65638..e18fc5f 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 2cfc8f4..626c5f7 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 26333f0..7369e0e 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 4bd258f..9dff1fd 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 45c102f..592be3b 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 03447c3..f240329 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 d4aacae..663c8a8 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 0bccce9..aa60d30 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 1988d78..abbd5f0 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 6a37633..2e9cd05 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 b8ceb45..f9bbc33 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 055821f..0ac1eb9 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 99c0877..d80f471 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 ef4102f..0bf5a46 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 29feb4c..c780901 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 0a0fdc5..06ead20 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 19c028a..295c133 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 de9026c..f714fd2 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 1ab0dba..e7f77ea 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 778a953..656a2f4 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 1be1848..56468c2 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 e1fbf86..fc283be 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 18e5bb1..2a28d3f 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 4e74c35..41ac494 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 2d6517a..58347c0 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 a46a861..40de76e 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 30f32ba..9d4a9cb 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 0456ef0..1db2ba2 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 92f2879..b205e1b 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 c33082f..f4bcf8c 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 2547b3e..b69590e 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 bc7074b..4817e5e 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 502b692..8dea611 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 a78a685..0dba590 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 8f5dc0d..1d5eb92 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 092b36f..45a9fdb 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 2ad3eb2..9fe1bad 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 56d42b8..a02bde0 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 9b92478..13b8bc1 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 81d8c39..fc079cd 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 9a13899..6597ede 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 b8fe156..c4ec8e9 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 3672bf8..3a33a25 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 f8da392..eacca56 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 af5668c..5cb309f 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 ca56c85..703742f 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 730ade9..521f4b0 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 2dd5b44..e49b114 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 ab09ba9..0d09091 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 5b36339..1fbd877 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 15cdf4d..2d7439c 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 fa16bfa..3d8da3b 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 1824a10..ada1242 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 8046049..cd7b7d2 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/85] 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 ab11878..6052231 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 8026f5b..f0497ed 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 660e0d6..44e056d 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 46d353f..614ad6b 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 0275af5..51ff48e 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 241ec7a..a874ab3 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 2a174db..cd4387f 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 716ff7f..223b88d 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 7f82eb6..9997bf5 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 e3db7c0..88ccef4 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 142b7eb..f72d12d 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 d8eecbc..43fb231 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 addac17..46675c8 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 bd540be..384265f 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 37cc807..de5a3cf 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 cf728a4..a07325c 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 9e77c15..ea29a5b 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 ff52fe8..fbfc42e 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 f768e42..9fc2f5e 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 cd8e7d5..136873f 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 70106a6..e7b5c04 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 b5d8121..c8cd033 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 5817f28..09b5036 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 25a7319..d15cce8 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 35fede3..f731b94 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 db4d6ba..1bd5b6c 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 e3f4ea7..64ac38e 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 fff1315..4adb1ff 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 1e7dc7e..5d33208 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 15c4c2b..9ffd118 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 cc9705d..9b86ce6 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 b88de34..3c79a94 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 575ca9a..314b0e1 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 1f4e9c2..7ecc1c7 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 9537600..1dec12f 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 8675fc2..7074f46 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 b759b9d..2ae208a 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 8783421..7388253 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 fb7a182..e63951c 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 096ddde..5622655 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 a663294..b7e0850 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 feff892..1dab40c 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 aeed5c2..dff0d9c 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 b6ba3ad..62885ee 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 62ed958..926c58a 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 324f4fc..42a1cff 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 8f3db19..80be3ae 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 b3d8f40..e53a44c 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 e7a6e5c..d1d6445 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 6eee0fd..c536b8c 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 4174339..378633a 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 a6aed18..32f72ac 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 5d451fe..c158186 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 05618c1..2e02952 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 1511055..3487eb3 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 ee7bf4a..95bc094 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 f8b6024..9c15922 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 30592d3..180da3b 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 12f844e..f647532 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 9ea2440..bb4e5c2 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 6e5c84c..ba5338b 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 455d017..a90d867 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 aa21f08..d91b35e 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 68c2860..f55b794 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 2787a0c..2ad3534 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 a4e180a..c353b38 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 6ff7498..d2b4cf8 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 80a64f5..160e86b 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 9f33652..c6f5f08 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 523e421..e38fd82 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 34eb4ae..8770c86 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 b00c23f..fc3cd28 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 0d6d34e..15b7bfc 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 78e21ad..081458a 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 fb0cd7d..1bd1273 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 92bbfea..95071c9 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 20c34e1..1217bd2 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 e3daa32..8069308 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 ca30734..e700a3d 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 63c2816..b2003fe 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 2279a79..5fecd57 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 03fc720..5234c08 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 f6c84ed..991f8a1 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 9d48c3f..8f583d2 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 dcd160f..0d6f2b3 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 6d75b7a..499c55e 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 1b98861..843aae8 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 e84c445..b2798f3 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 d4d28bc..e556ccc 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 cf1c163..f736b7b 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 c5b55f8..e9f412c 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 39001e4..7a6d9a7 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 74cb365..ce028c5 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 19eb5f6..8387ba6 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 3b56a5b..68da325 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 9524f2a..315d955 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 2ad93d6..ae98819 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 8c9d34a..c47ee41 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 3ac21ff..15eeeb3 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 e9964e8..690bd8d 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 0a354b1..a730aae 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 b58ef3b..d0ddcba 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 6885d2a..77c4093 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 ac9aa9f..1535207 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 503bdd1..456d7e6 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 579f4fe..2006c5b 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 4ee87ce..48e97de 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 9c181fe..955e4d4 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 e372fd7..a07df24 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 f66dedf..ce9a3e1 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 66ebaed..730c1f4 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 3f44560..4e23e04 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 892e502..1a9fe6d 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 5dda85d..669461e 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 f310efc..8ddad88 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 4cab84b..b65cfef 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 4923c75..9bdf6ba 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 43f76ef..ad8172e 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 b11d4ef..99c53e8 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 8053d70..cabb8f7 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 95a8586..b4928bb 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 cf6d8f1..6ec4797 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 b1a6681..73b1163 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 13f4424..f90280a 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 1946824..eab5da7 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 b4dd4cb..52eba02 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 a669838..4c4756b 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 b856e79..52cebd7 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 d5130ad..f7809af 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 b500e91..1878d42 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 84e2819..6f198d9 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 3ce7f8e..5248247 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 d7745a4..ea8a0d1 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 92bb1f4..6e40195 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 cd404fc..88eaaed 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 374b8fe..4117c12 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 b12c037..c021130 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 8230743..af61aa3 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 c3db0a5..d5dbe8a 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 8f689c2..6c2c2bf 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 ed39703..be303d4 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 2344251..c383bad 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 6c2baf7..bfef0b3 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 e9f265f..6b6f95f 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 955c3ea..3870a7a 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 c4e7be9..d8c301f 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 83b95c9..2fc5648 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 49db002..3eb6676 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 ac0055c..2156444 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 67eb097..49f6763 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 5dd8c8f..95fea23 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 d46882a..91713cb 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 e243973..513b5f1 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 9a65acf..409f7db 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 0bd927c..703c967 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 beeea7e..c7da59a 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 b082b5a..c075961 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 b5be092..4fab045 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 d19d0d7..4e3502c 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 3545f4c..7d9bd60 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 ee32523..0fea952 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 420a81c..ad529d7 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 cc0dc8a..1d28903 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 8a0ad5c..2212e8a 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 6ad7094..4efde12 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 a5b3b2b..ef8a084 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 c704df8..3c108af 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 8e65038..ecb2094 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 1c8637d..ab50201 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 3c53b2d..2419771 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 a4ab9ec..5b0fcea 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 8fcc142..d889ed8 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 bda2064..fb96a7b 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 bf4770a..98c5d56 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 ede7915..6e5eb9f 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 aaa00c9..543e148 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 a244569..b971db3 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 c714e60..c9b4da6 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 d2603c2..0c63a00 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 5921bfb..9f16379 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 b98a7bb..a92f3ed 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 21f2d1c..0e5833c 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 ebb178c..6ef854f 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 047ce0b..9f13ee5 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 1446d79..7ddc9bb 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 4080e49..bf1f5ce 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 0b53126..e926f2a 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 744081b..9db68a2 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 845f915..b3d1923 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 52a28e2..d7e2750 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 6c58111..122f4b0 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 021432e..e1aafcc 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 4077745..bbff3e1 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 71bbf3d..2089d2e 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 ac59e14..be13bf1 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 7a2bd11..7bc2970 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 1fe0eb4..097e35c 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 15a7e23..c960850 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 ce57bfd..43afa62 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 8e2ce25..23aed70 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 5106304..cd46f77 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 6e6f58f..554dd40 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 b5882ac..72c207a 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 d545699..c3222fb 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 18d3da4..ec09a78 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 a543925..d7cb369 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 1064813..7be32b1 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 95578ca..e7570e2 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 db4a7f8..46fd240 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 e706b43..43c8811 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 f3924fe..889f275 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 021531c..7c9aa7f 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 9496b5a..89ac7d5 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 50610e8..8cf5fe4 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 9c3f2ff..30aee4f 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 dfcd574..c8e1964 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 2701ed3..9a1db8b 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 92ddae6..3b4d748 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 8d22092..7522678 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 fd72aac..11680d0 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 e9ee24e..c912206 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 d212464..12ed1cc 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 8a0b4e6..086dbf1 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 dfaa571..c657bf0 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 82b40ec..dda6b5b 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 8b91638..57a1a0e 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 36560fb..44c44ca 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 b6006fa..bc49fc4 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 05f2b35..a099d9c 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 eccbfb4..1e7bf06 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 00c3e82..08101a2 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 27e10f0..2b9aa44 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 032ab01..7b30f55 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 8c27ddb..315ba74 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 9058f16..0634c01 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 c790ac2..4eb36c1 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 3b27ce7..9540da8 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 0072595..6411350 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 db2c209..bbe6d77 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 d91877d..750652f 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 94a9c34..5214bce 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 5c1f0c8..96f9e1e 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 008d1de..d034efa 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 185e058..0b46e21 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 93e2036..79828f5 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 788a8ca..f848709 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 6714f4f..e2224e8 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 afb4bbd..2326db0 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 9648203..1cdda61 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 1e22c86..ac98b50 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 855feaa..3ed9a62 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 5644dc1..0768814 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 e0b6b0a..bc2f78e 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 22c6f0f..bf9f91b 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 d97f7e6..ae90606 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 9d60e5e..6eae8ea 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 bb90c1a..9741a9e 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 1e9e25d..db91fb7 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 c4155ce..e2f736e 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 69627ee..cb903fc 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 fb6a545..44d0642 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 ae25a9f..81258ce 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 968d669..53db492 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 d615388..bf5a05e 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 b340770..f8913da 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 775b0d5..280480c 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 766ac4e..fb398b9 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 58fe22e..ba14d2c 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 110f213..d979a18 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 4bebf08..f8ce0c5 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 0975335..0c923be 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 13a6db6..a7c4a2c 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 b0f634a..b8881c7 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 1681221..0feded8 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 71b89c1..951ae3a 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 2ca18b4..32580e4 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 03996c2..dae1f2f 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 d8b4823..90b6c7b 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 bc747ca..b0bcacd 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 c5da28f..c18c954 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 403c1cc..8f39352 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 fd64adc..70422b0 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 fe4550f..6c16baa 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 818a3c1..9f7692d 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 1ce4f8e..6f7a19d 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 cd6b76d..5f02d66 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 a48c1c1..8dafd4e 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 4e5e2bc..6a95abd 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 44a8391..3bb6873 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 99b8d1a..9bfa6dc 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 d4a8a0a..f997d4f 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 8d2617e..15c7834 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 4eea0c3..27019a2 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 f39a4b8..1ff3310 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 4595e8d..b037e77 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 9519c80..a67c918 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 607fde4..298f8ec 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 0d26c33..bdabd9f 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 439e9ec..6898af2 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 bb4c169..abc268d 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 c98d8e4..01d3dda 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 dfd5f78..3c48f79 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 22252d5..53898d7 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 4d61560..eaac7fe 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 1c8c918..77a045f 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 9c7fc71..f797dcd 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 c11c238..5942f42 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 185c124..3a2e28a 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 4789586..8cb9e20 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 3727308..8acdd2a 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 8f0c4a4..ba9ac25 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 969880d..dc924b4 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 271d70b..e25bc0e 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 c8b91bf..572bbdf 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 c19c0bf..94dcb2d 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 15dd2b3..d601836 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 952cc84..370d70b 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 e5126ad..87f43cb 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 a4b87ca..9c7dd86 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 0422761..f197444 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 e619088..e6640ba 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 2e8b382..06eb505 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 a766744..af70fd6 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 0cac30c..c7d3c3f 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 c120f7d..e361c7f 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 b307bc2..d38d26f 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 adf2ffd..5f785cb 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 2e8972f..f83d77d 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 d891dbd..af57484 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 2c743ab..13cb475 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 74cd8de..4b55f40 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 9dba29e..dfb3061 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 6c449cc..f4e24de 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 05c28a1..e90400a 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 a29c469..0b7925c 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 00cee50..3c47298 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 13d694b..1422fab 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 c2c9998..8bde234 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 d9b8204..46ee513 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 f4aef2d..1a51cfe 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 fbdf72a..d2c9fb3 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 5623c1f..2ca1044 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 1cf9e43..85279af 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 d48dd8c..57d8014 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 d1e19a9..b7e6b7c 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 1389fbe..7bfd22e 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 2d7af17..732fd2a 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 dfac2ea..b21559f 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 01f2e87..7759d96 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 da6868d..cde5b85 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 b3c7a3b..ed410e2 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 9cdc9f3..6b5ca65 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 1e9ec14..7207960 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 b17b829..0909088 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 7a89e1c..7bbce3b 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 02dd8fa..37042b1 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 d30cf2c..a568d7c 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 99f70a5..79850e6 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 0ac4e56..0751007 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 d96849c..1cb9548 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 842832d..a8be0a4 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 1f31e09..d1274b6 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 f5d6066..969014e 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 d4e0150..90b0ccb 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 5c97ec6..9273ca0 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 fe2000d..485cf4e 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 d1b6a95..6cbd1bf 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 875ed9c..cc9c7a2 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 4d0e7a0..d1394d6 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 61ff1e0..b830c25 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 5a4e4ef..bc3da86 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 c75f03a..43de6a8 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 1cdea93..6ab335a 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 f967a12..9b8931d 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 709cdf0..18fbfbe 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 aa0b6e1..26fb4fa 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 9a4ac72..f5fa2aa 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 b98f9a2..a037ac1 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 a389b91..743f4b0 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 adba841..af348d5 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 c36007a..ace5d4b 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 5a0532b..e030426 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 553b6d5..cccc55a 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 91bef63..74ff46c 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 c9b6d6d..8a1b88d 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 0613a9f..7ef9f96 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 4811f00..6cae906 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 a8d5df6..6eaff86 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 ebed22f..b483310 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 91e4150..1186825 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 5600404..39b1924 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 143848f..0025e34 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 896e55b..2761cda 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 9c8ad82..c78c048 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 bf19545..f7c5cfc 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 aae3f0d..80eb992 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 2f60ffd..a4567c3 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 a75d3f9..e871d26 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 51a85d0..04fdb37 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 b8c8cb9..3eb40e6 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 aeeffd2..41a58bb 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 bb6c566..84c798c 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 a9b4a87..a8bcab9 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 29a496b..3fc179f 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 5b31f0d..d1d4946 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 98222e7..2695f58 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 92b2c06..013d2f6 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 2a4e5ed..5302445 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 c828274..c06a2f8 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 ccaae25..7dd8ffa 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 fb106d8..a1cb8a9 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 3f22b3a..83f944e 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 bc60afa..1db9505 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 387f135..9358212 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 e2fc16c..1003e2e 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 93dd31c..73794c5 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 fa9dbc6..56d86fe 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 cef3c23..938ce7c 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 9990c37..48af075 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 e7f2577..737cf37 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 9406912..5370be3 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 4e938d4..d77f43e 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 00c3ebf..b8cc788 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 b45bd9a..c5c228d 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 8c0c91d..5f78d9a 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 7e4d648..4f1097d 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 3c4adfe..34c08f9 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 bb8c6aa..8900ee3 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 664f34e..2abf87f 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 0664b4c..be8d61f 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 e02e41d..2190aa8 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 69e33c1..f815237 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 16980a0..e5b6d41 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 95679e4..5b27672 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 3a091ab..ba07e03 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 b13d834..057c9a6 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 cb38278..0c04521 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 ff121da..e7119d0 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 a6f2654..7fd9ac3 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 6b1ce7e..90c0b8b 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 a6dbaf7..28edbae 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 14104c0..a58d1bc 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 4fa2df0..7e388be 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 4037966..1f3f9ed 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 91a2ee6..9171b1f 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 b24702d..e610573 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 ab2d653..c01138d 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 4b6cbd2..92c5698 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 ee595c9..7b667e5 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 c2fc8fb..81a4532 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 bcd6216..f3da36c 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 90b5463..c1fb889 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 a47bf2d..34bb880 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 948b429..8bc4169 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 10a076f..fcc2ff6 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 48bed45..041bf90 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 6ecc486..54ef23b 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 8e5badd..b48d15f 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 966d2c4..e32bbbd 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 60ec96b..601d1b9 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 7e51779..14c6556 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 1c64db0..8a15b00 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 da43b0f..cdc7f90 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 cf725ce..a1a2ebd 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 fdbd16b..003edd4 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 dbe9872..f1a9b09 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 31e9766..e09a0f3 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 f32a3d7..6432aad 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 840564a..b758319 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 9bb06c4..dcee961 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 efb1b0d..7dff374 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 57f1039..53bf082 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 8690f73..5f05c47 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 df53246..10b2364 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 59434ae..9a36898 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 b63eb9f..b7456ad 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 2708923..c134e27 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 109f32b..8b0c04f 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 03f528b..71454a4 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 7763aa7..37c559e 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 70f94cf..491f73c 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 2ee8baf..419db05 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 cb70c9d..28aea42 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 2d59a41..2ba9830 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 e3ebaac..4ec4529 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 1402327..0e93c17 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 6cdf410..3b32ed2 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 5a23869..9971111 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 a1ddfe9..1515b7d 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 60e39d6..b900047 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 330958a..d9756dc 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 7157017..b71ea7b 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 370b603..5369205 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 ecdee21..450d5fc 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 79545a5..6b66367 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 aef1b22..ca25edf 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 6228706..75f90c0 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 324d303..2e1bdc9 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 89da981..49fd3d8 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 4fdc919..c04f2a3 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 367b1c9..fc5e8ea 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 213b596..b89431e 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 6c84e3e..2a40fa4 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 84955b9..ae91f34 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 ae02028..44e4de5 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 8909a26..dfd691c 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 097b5a1..21e774f 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 74718f2..102e17a 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 31fb0f7..9fbde2f 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 a48d4e9..aa6721f 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 2c2a87a..5bf3e21 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 113bb90..88722e7 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 1668736..fd27dfa 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 1b9d0f4..bad18fa 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 2a10f3b..da86fd7 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 9868647..283f887 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 03a46ec..92d3442 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 610e727..0da3e4c 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 877e2b1..91891e4 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 a2e3f5c..148996e 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 418b583..16f214b 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 c45c35f..3cabaaa 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 dc85cf2..89828a1 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 590613b..26bf20c 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 a8bc397..8397fda 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 f3eb939..fcd3557 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 139de34..1b8b4a3 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 3b136b9..0d2627a 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 1f2b462..adee1fd 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 3bd55d7..fd4069f 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 595baa6..97b254c 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 14a14f6..588d1cc 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 935c357..f5d9fd6 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 4efd73c..e9ebc9b 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 73b8250..325ea7b 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 13002e0..807666f 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 b11c1d4..3bd227f 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 3568f00..652243e 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 5cbde78..eec98e0 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 e9a7b18..e67cca0 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 673b709..37d9bf9 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 27100f8..f44633e 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 b4ad533..e8d7520 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 1a6d65e..94ff4ef 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 2788e86..71d9478 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 a7b2069..5fc5afd 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 bffff53..d608033 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 4be0628..f3d8de2 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 360aa1f..4a2f5ce 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 d13d719..dd37f4d 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 4dcf2d6..58b841a 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 8b3ad8d..bace53f 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 f3dfb9b..e8ebf61 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 4dfe58e..f99802a 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 705d79d..5da326a 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 864ae25..2a39574 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 2fef7d4..b886ba1 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 722d610..d28e206 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 f8110e1..e349f99 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 c0c4ee6..26d7283 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 c94f209..0371d9b 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 a965012..9b4387a 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 d247f36..9463d90 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 48c30d9..31041e9 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 842bc6c..131f1fa 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 34e5624..18a555a 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 8a70c1e..21acf79 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 f5adf61..62438fe 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 4c2ec9b..98546f8 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 7824fa5..b941407 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 7bc4ad9..36b347e 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 bc896f0..7f71858 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 959afab..871dd8b 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 7109d19..666ef39 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 002a1fd..5016ca9 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 b34baf5..d76ed7a 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 57729f6..cdb44e2 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 24d1ccc..b1041d2 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 1948de0..ae40572 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 ecfbe40..d8a3f40 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 d69be67..7045ab8 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 9c52297..4831e2d 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 2ffaadf..0d4e1f8 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 39cb069..853f639 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 0f9af41..1d36b2c 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 9a0a012..5852412 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 d31da56..95c798b 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 352e297..e1f07b5 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 abf1c22..076915e 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 531be9e..4233a03 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 bad3a35..58ff934 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 3a3bfff..f6025e8 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 9b74b44..b67f086 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 e6c820f..91abe46 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 926f1bb..394a489 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 cf69d92..e176bc5 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 ff490b2..b995c01 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 a67387a..d141ad4 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 021a346..3704267 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 2c2c2c6..403b097 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 912a078..c6cb3de 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 36ce72b..8291a90 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 17ef4f0..71e6a77 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 b70a94f..65abd0e 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 144807e..6b43292 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 9f783e5..d4f8221 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 9f9eb1f..2ed299f 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 058b5e1..1945cc1 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 f1e0443..f79442c 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 98497c0..7b61bb1 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 f604dc1..d923aa6 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 5014369..0dc4286 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 95c76a6..07a33b2 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 8a112bb..c2896ed 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 05c7b78..33b1e00 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 3223325..f8d44b6 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 babf827..3a1ce20 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 1bfcec3..beda5e7 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 38f0a29..e6b0fc6 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 c495060..8227f92 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 5f2754f..0d0ee63 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 2bc552b..b128222 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 6b4a754..ee4b451 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 3a6a68b..8031c36 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 683f033..714cff6 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 f3df1a6..facb195 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 a771196..4156caa 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 51693a8..98c9cfc 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 b79e4ab..47ea999 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 bdbdf42..95deab0 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 22f9ece..22b4aab 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 290bf26..7dd9b4a 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 b57d128..7c33ef5 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 5798a11..714f891 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 8806833..1af717d 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 1344805..0dbff50 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 3a3f73b..49d086f 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 063f8f9..0177b20 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 e9c6f95..bc6eecd 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 5eca79e..b76c7af 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 b694675..e81d4d0 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 456ed8e..1c24e14 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 510527a..b41f6a8 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 aeffe52..3d36f1e 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 7fd3b9a..b89ac9a 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 1d66f24..069e857 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 a082af3..9e7446a 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 bfa7f5b..70fe4e1 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 8487610..466a642 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 8229f21..5a9a1e2 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 9ba6f9b..82aae24 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 33cda47..430a5dc 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 0134d64..df39054 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 17041b7..20a6d99 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 0d2b069..3b0f164 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 095fb84..5a4afbb 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 99fd886..196ecd8 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 8c75785..81e9ddb 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 35c4bcd..fc2eba2 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 8df30bf..d41afb6 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 bc4d468..b678201 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 3959cbb..25d92c9 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 604ecb9..f02383a 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 b132e5b..2ac487b 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 2cf35a0..be3833c 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 cf8390d..ccc8362 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 466450a..e2a6d20 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 1b89460..7c981ac 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 31fac08..59847f4 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 675a29f..ad9b9bf 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 8222026..fa1d277 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 9f64bd4..e772df9 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 cd23705..20a7bfb 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 c277b18..2ff522b 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 1c60e72..754ac30 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 387bbe1..47f53bc 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 e381496..d7b088f 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 bbf05df..296c2c0 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 8275660..be15269 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 e883ae1..ac8b5b4 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 223a41c..586e4f8 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 1928c4d..3c08875 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 4662221..6743c13 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 ee38745..fc858df 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 2440fb3..13aefd9 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 ef459de..30a8fb4 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 3a6ec19..0d52453 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 bc6eb46..b7bede5 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 a1dd342..b047c9c 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 c1c7be3..b14c6e9 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 4a3c16b..d5b2a13 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 6932201..efb23c5 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 8c0a2b3..738954f 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 fa02c93..40427b7 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 fbc1756..2314e94 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 f73a09c..78be73d 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 fe31211..ac4c5dc 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 639fa39..a6bb34c 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 81b32b9..62325e7 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 16f0d9b..9234fd8 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 d40e624..bcfd585 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 1258b86..3bfa709 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 0693424..0f3b520 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 84d3174..1d0626f 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 4287349..cc3a270 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 4b4a925..708277c 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 a8c6316..ca28b55 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 f25a28d..9286bff 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 68d293f..2048de9 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 69d2cb9..afa4fb7 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 c031ff1..f976139 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 5f09bd2..58ea6af 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 3e8160a..4574c7e 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 f802420..8cac4a8 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 bcaf40f..a5ca021 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 b1cf4f2..a42d356 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 753ec8c..badaefc 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 27b0940..0662949 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 ef98614..fea1721 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 118fd31..2b0e310 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 e6f35db..48cf996 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 fd4d430..59ae6f5 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 429f000..504a151 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 0691505..32f1602 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 0f2c1a2..586a6a5 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 582f15b..f7d9f30 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 a9a0a53..4aca030 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 c298d6e..7357bba 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 2122aaf..41f6aae 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 36c3404..51f0558 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 ee9d3a7..71044af 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 86a04c0..df21824 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 8e6e168..452567c 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 3a9994b..614001d 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 b87b7ff..aa8df89 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 81c0ab5..2b5a6c5 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 e4e784e..f2d4358 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 4b12a0d..61dab38 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 d5a3fb9..f0c6b28 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 945ae40..b34716a 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 b5667f5..7074c43 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 01eabde..0807f5d 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 ddf4e92..34d2946 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 6ef857e..ab5b3e8 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 245f2f0..524d78e 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 662bcd8..1a2b04e 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 7e92c08..4297785 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 d81ee67..332cee2 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 2844522..ec2c26c 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 ce8abdb..869ced4 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 f7e0caa..939d126 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 2e3f9a5..a946b15 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 afba779..65d35f2 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 a99c2c0..8d61aeb 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 7799721..5853aa0 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 4e804a3..626255e 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 e103d7d..e2053ca 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 e40bd7c..476b5fe 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 355b1b2..2dc8d38 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 95ea604..89bd095 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 eeea0a8..fd57763 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 9607189..b8285ea 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 4cb0a68..31bda64 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 f1aa579..4b74474 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 64ad6c0..b54286a 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 bec32c9..c1f03ee 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 4172819..7f97690 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 99cef96..8ea6f3c 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 adaff35..045b8b5 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 8f7d209..0f96928 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 03b3d35..15de4ce 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 6569d00..b3b65a1 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 aff5bca..93c8567 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 8e7abd9..b9f8c02 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 b58669a..be1b1d4 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 2d65ebd..e8ab57c 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 902107b..0d6ed66 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 1ef8c0a..8cc77e7 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 db14872..4f127c5 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 ad99d47..e7316a1 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 02ea303..0787078 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 096df48..18dbf1b 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 585dd31..a2e46ef 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 aae55b0..0499572 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 8b870ac..701d050 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 f80d3fb..cbf5812 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 27b020e..8b41c64 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 14ae9b6..c482cfd 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 b99358f..cebac11 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 5248ebd..ce89026 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 5a824bb..3ebeb20 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 13c6a46..a4c7c59 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 5c07c8a..a350c0d 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 47012f1..6a5d3f5 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 c1f705b..f1f1971 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 9a84e0f..3a23304 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 a785f02..96d7449 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 74722f8..97bb10d 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 d4792b5..d3d51c4 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 4c9997e..0f52982 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 c1f4aa4..6a47d69 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 912aa69..6091722 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 18339e4..b16fc55 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 b9c88b0..b6dbd2c 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 0b83e27..40637c4 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 941da95..0fe1eae 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 01397f0..b02265d 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 660fdf9..e351615 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 fd1b672..52b3eeb 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 b5e5897..6a8a8ec 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 f6dbd2d..211e8f3 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 8eae521..a1b4e6a 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 1237d41..23c66eb 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 1fb7da2..28aef8b 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 6974668..deb0956 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 a57ca6a..20e71ee 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 5b8e37a..7293efd 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 747c8e3..49950eb 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 0c42a52..6da3af1 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 fb7d89f..069027d 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 de495fb..c211266 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 5f8f7c9..a530b5e 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 89921f3..aba47a6 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 b9c59f1..325392d 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 6b966c1..6ab3e47 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 3c5381c..0257f78 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 3cef5d9..3898560 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 d49f5b1..a36b693 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 7692172..e1a6679 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 49a9e75..45f701f 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 6dd0207..4bb2132 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 8da3fd5..ad73387 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 43c7330..3493492 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 be0750d..9527215 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 215a4cc..27daec8 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 a632b47..8e28d9a 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 659c49a..cd9273c 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 bd750a4..5144053 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 0a05f88..5195a55 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 2a0ce84..1ec2fc0 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 7df5a90..556e0b8 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 7b1dfc1..b71f810 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 c1f8705..c54d72c 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 befe889..aae739f 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 a6e5b4a..8ad1ccf 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 d5fed20..fc0e6c7 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 eae41d7..53d449f 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 2ebb9f5..db416bb 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 0980d39..20376af 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 04177bd..607762d 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 7faa679..c83e7d3 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 ac007b3..aa82eae 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 1223f19..bb3a38d 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 d667672..a38e753 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 d6405ac..723f4ec 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 e0a9255..1d31d4a 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 1da68db..bc18e14 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 9793843..1402713 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 b721f9a..4019654 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 0e55e24..f2a9ad9 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 e772572..0fe15fc 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 4724598..46349f1 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 89a9c9b..5fe2a37 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 f842237..9fbe1c2 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 763d5dc..82527e5 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 40bbe83..d6a8999 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 c3e9023..7984e8f 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 ad88eca..1c5a22d 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 a11a8ea..5151126 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 3d4a6e9..6733e40 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 9d8ab5f..0235df9 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 ed9accb..dd6389d 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 f0d4bc3..7708476 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 fcefb45..563916c 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 a83263f..7380e23 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 cf7d073..7702ca8 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 061205a..c233413 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 c34eb2d..0343564 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 e62b54b..6052299 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 303207b..0410ef9 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 36c0038..6c4845e 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 5c59e26..dc8760e 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 63f07f4..216b9f4 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 09e6b0c..f3a04cd 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 3bf553f..ab0b9bd 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 20086b1..aac6248 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 531b54e..fbb037b 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 9e1d3fa..75e17ad 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 2fd552d..b9101a2 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 c238253..126ec0d 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 2123022..2579007 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 6b6b2ea..bbef472 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 39ed0fb..ae0228b 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 e9aa6ea..39eb4c1 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 6cfbc5a..f0668c3 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 b904bd0..ab7a09b 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 ee8c04f..1d470be 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 5f597d6..c061646 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 bb1feea..0ee1ab9 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 79c211b..25f52ae 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 552b459..1d62a03 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 a1a1eda..d26048e 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 b613d67..1bc789b 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 2c0618c..76c02f9 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 35c5491..2d9cad4 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 86e0461..b6745b5 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 0059789..c54750c 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 543c19c..fa97885 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 79e9c95..0dfb499 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 e610a1e..6af2c9c 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 538d9bc..3247928 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 4a55d68..fb0aa97 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 122b7ea..4160c21 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 d0b628f..a58eaa5 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 0fd50fd..e6b31d1 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 4757c76..f29f173 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 25b0b07..e18b11b 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 6348efb..800e450 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 f7e501e..ffb0ae5 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 26e3bdd..757981b 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 5a979a5..9426fc4 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 598947b..2c4ed54 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 79898cc..9f81509 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 3e0133f..f98b6a2 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 d89d1f6..74b6b71 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 f092c7a..c43ae8e 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 29c4903..4aa4bb8 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 8b62084..ea1778b 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 3dcbb18..75bdc38 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 31acbe8..a6ae743 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 d56ca88..56f1dc2 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 c7b6c2c..3b496fb 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 855e75d..e8ab0dd 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 6898537..8ce56e1 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 1635c76..39e00fe 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 9a1cb3f..3826c67 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 36f4073..e0c3827 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 935c283..4650a42 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 670d934..88d25e9 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 47af0c2..f4a68ea 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 641e202..c2ba0c6 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 4270592..7b7f57b 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 bedb28d..78e7ad3 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 4283f78..bdef2f1 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 162d24e..092c39b 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 16852de..554a395 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 5765585..ee93b73 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 6b306ba..cb5068d 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 1eb222d..86dcd64 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 10c5551..231a27a 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 565538e..eec7784 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 a8b4bc8..a3c6a4c 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 0664e36..72e0146 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 1ce474d..9331d1e 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 c8ea61d..e5c984e 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 ea3ff51..4171119 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 a0ee8b3..9470791 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 93ac61c..7cc1f95 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 c47604d..e0621d9 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 5da445a..f0881d4 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 097c58f..741c7ad 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 e4d78d1..66e4b10 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 5b9bdb8..153a5dd 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 250d3dd..46c502a 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 66ac3d5..e1ce185 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 a6615c9..29a3b28 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 c1ffbe3..5e9c030 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 6c0e228..c2fe61c 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 b10ef12..fb082cf 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 a3aceae..3b428c8 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 0ebbb00..b1d8db5 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 de2c12c..e79a995 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 73a09da..76d6add 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 389246f..41c4b9d 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 f2e500d..534d09e 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 e7e1fe4..2799fe8 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 51debbd..431a00c 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 4cb902b..09b9a2b 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 220df48..321e845 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 0962f84..010a83a 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 07ddf7c..3fbbee9 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 a583d66..6e640c7 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 36f61ff..a806927 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 aaa7af1..48747bf 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 2865251..be36553 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 9fc5f77..4d49dcf 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 445bf36..be19ce2 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 dfaeb62..6d9053d 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 938b3b7..bb13c5c 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 04a4ddf..25ebd4c 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 e8db331..5b8c9eb 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 0157658..4426d98 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 f40bcb4..89ac227 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 657c201..872ebdb 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 fd2a426..7dd233b 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 5e9f908..e49ce69 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 66a0b24..3cb238a 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 b0e3fea..239413a 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 cd36b1f..7076c1c 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 629c9f4..69392ab 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 fd54157..e685189 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 9bb0693..938b390 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 9c1f358..f3685a2 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 a5ba976..bbf69b8 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 7dd0cf1..9af79be 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 21bdd84..3ced22c 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 1fd3458..e22390b 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 c808a37..c551305 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 d46b09d..33e6644 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 050cc2f..a1f1953 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 9a21e29..5f4804c 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 04a523c..1b1d339 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 cd5e08f..618f964 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 1d7ca14..d5ea86f 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 b3b966f..7a9951b 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 e7daad8..92ef14f 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 1ec60b8..15de232 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 1457178..19397df 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 b09a188..c3d7aa3 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 8451ded..1cf5341 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 b3c4155..928eb7a 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 859764f..15d93c8 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 de7ff95..6704522 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 6be6d65..e8213ee 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 fe8128e..b514e2d 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 69e4f19..6f10ef8 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 a3c59f2..7f68cf4 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 0bed127..8da78b2 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 250bfe3..0fa3b60 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 989a560..33579b6 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 54f410f..2fd026f 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 2bf11b6..55a5b50 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 14a2f11..b9b78e4 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 4dce41a..901cf14 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 9e06f67..ea63f85 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 edf2ffc..08f8dfd 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 3854d86..5df298e 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 bea2c25..19c714d 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 c7e49d7..309eb89 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 3690fb9..77e7dcf 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 f5368ac..8369837 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 a63cc1a..31fb6df 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 5c8cb06..88a5b22 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 52c29de..cbecde9 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 68f57d8..a9c2958 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 82a6510..3bc7d9b 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 2c9394f..818d47f 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 9081a30..f942afb 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 2fb4865..5eb260a 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 eca5ac7..d9ae35f 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 1fb8aac..064dcc6 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 abbfaea..d15967b 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 9864f79..f3eae4d 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 ed29c8b..83e2c70 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 2399a41..11a86dd 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 ce5fb94..faea86f 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 fc99fa9..ad50b58 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 467816c..486488a 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 a13cafe..e185fdd 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 1d171eb..234e2b8 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 1398517..25bfd5d 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 8b37cf6..11ad371 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 21b1d8d..bab9f7f 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 e7da22d..e353591 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 a37b146..067b7b5 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 1b68ad4..b786b0f 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 6c11513..dd69356 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 991f05f..09e24b5 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 a6b70a6..2677729 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 297d6c7..e1dc4c7 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 01a0ba0..d992d81 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 3db574a..2bc93f0 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 772a1c0..7976078 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 25a8de5..7bf454f 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 e048ba5..f206812 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 c23f259..0a6a26b 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 0fb5cf5..823555c 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 a04453c..e78fa46 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 dd4211e..cc926c1 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 e9e09c2..cc7d71d 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 e757d83..744cca8 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 ee8777a..846687c 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 4509bc9..089f46c 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 58c43a3..f7d88e1 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 827c294..1e46b21 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 7e90491..4b71b59 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 e18fc5f..7dc96ed 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 626c5f7..0c44795 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 7369e0e..1ce8be2 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 663c8a8..a88e096 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 aa60d30..59e3e9c 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 abbd5f0..643ca8e 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 2e9cd05..454dbef 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 f9bbc33..713c531 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 0ac1eb9..ef4b9e9 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 06ead20..231544f 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 f714fd2..c104343 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 e7f77ea..f3c8632 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 656a2f4..9d2aeec 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 56468c2..14f01ef 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 fc283be..d576b54 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 2a28d3f..bc049f8 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 41ac494..c787878 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 9d4a9cb..0d6c03f 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 b205e1b..bea2d8a 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 f4bcf8c..1454071 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 1d5eb92..3cda0d1 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 45a9fdb..dcdfaa7 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 9fe1bad..1abeb83 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 13b8bc1..5167a06 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 fc079cd..44181fb 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 6597ede..662224d 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 c4ec8e9..4fe47ea 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 3a33a25..5539560 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 834d768..f0e9b58 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 eacca56..9d251ba 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 5cb309f..9030981 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 703742f..fb7a699 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 521f4b0..a1eb2ea 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 e49b114..697d323 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 ada1242..1824a10 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 cd7b7d2..8046049 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/85] 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 eea042a..7dbaea4 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 37fc32e..849e8ad 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 8778643..384337f 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 98abbcd..1b86666 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 1509f44..9a548af 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/85] 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 0ca3d2c..a96b201 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 d08ae8e..2cb6a61 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 fb6065c..f63849c 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 33ac062..c25f8e2 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 deb76af..c01d3e1 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 072a9bb..d6caf96 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 c6cd40f..da68ba3 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 71e0e71..595cdd2 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 e666c77..d6c7280 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 d24a553..a5b94ec 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 725d81b..e2ef978 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 3ddaddc..9721ffc 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 893f2bf..b793e5b 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 ef50dbb..810431f 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 2f71bea..0475f88 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 bc45404..49c4645 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 e3dce4a..b2b9034 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 12b9e90..c31458d 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 5053170..9305e89 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 b7d0794..ef28517 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 a097d6f..6156f75 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 2a38c83..cac908d 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 a61a87e..33c5dfc 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 b9bf3bc..704de22 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 d99c3af..f45d464 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 1cb8c76..d0e3477 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 fc5771e..4e50936 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 9e1c730..70eb547 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 a630ac1..aed1eba 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 6628b28..58800f4 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 1f23db3..ba9247d 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 b3b627f..511ea82 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 a64cd00..4c51ea4 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 31ca38b..bb41296 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 615fad5..df4937e 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 4557b84..72e554b 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 84bc383..4772b22 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 201f3fb..ac94396 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 1ce4511..9bec370 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 71427c8..4c694c0 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 8c96684..4c8752a 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 28bd68d..237675c 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 2b93150..d6d661e 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 1a77c2a..61550c1 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 89386f3..1a5ef3a 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 bae6cdd..a62a293 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 17395bf..defada7 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 432157f..230ee28 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 33773bf..124883b 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 150c6d8..f89fbd2 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 fcf4045..8e2e548 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 8e15552..f6ea996 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 9c9bb22..17de966 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 1428e68..ca0164b 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 3f9a6ac..08c8fc7 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 a683fdf..0222908 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 0fcf7f5..31a91c0 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 e53a3f7..b038ec8 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 02b929b..74697e6 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 347beef..646e277 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 c9389d8..5e26b89 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 22021d4..470497f 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 78eb451..409481b 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 0244ebd..88a9ad4 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 4ee4096..e04837b 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 aae9fb3..1a14fb5 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 d8b14bd..330ff34 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 15ce27b..2d1ad9b 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/85] 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 0000000..343e669 --- /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 0000000..b39026e --- /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 0000000..0118974 --- /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 0000000..e7c67a5 --- /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 0000000..b142983 --- /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 0000000..96fe6bc --- /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 0000000..81809a7 --- /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 0000000..1f0efaa --- /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 0000000..1d8ef81 --- /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 0000000..aafe38a --- /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 0000000..d313d71 --- /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 0000000..fa94129 --- /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 0000000..6060335 --- /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 0000000..e185c02 --- /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 0000000..8d86c91 --- /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 0000000..f8b81ce --- /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 0000000..cd9cfce --- /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 0000000..8494261 --- /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 0000000..22585f2 --- /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 0000000..768d558 --- /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 0000000..1bd364b --- /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 0000000..1b786da --- /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 0000000..d16334e --- /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 0000000..4918732 --- /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 0000000..a4b2e8d --- /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 0000000..36288a9 --- /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 0000000..bee2c86 --- /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 0000000..ff2fe7d --- /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 0000000..0192532 --- /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 0000000..2988571 --- /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 0000000..4aec2c1 --- /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 0000000..25edd74 --- /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 0000000..6a59c6a --- /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 0000000..1bbc910 --- /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 0000000..71b43ca --- /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 0000000..7e292bf --- /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 0000000..b1e4525 --- /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 0000000..ac8090f --- /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 0000000..d866fb0 --- /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 0000000..2688ee3 --- /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 0000000..a71a621 --- /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 0000000..92ca86c --- /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 0000000..ed3306c --- /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 0000000..3cacbe8 --- /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 0000000..3436c95 --- /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 0000000..27c50df --- /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 0000000..f00bb79 --- /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 0000000..f5fcd83 --- /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 0000000..abbe8ff --- /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 0000000..337545b --- /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 0000000..66c6271 --- /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 0000000..4ce3eab --- /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 0000000..0bcd083 --- /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 0000000..0d870f6 --- /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 0000000..7ce32ba --- /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 0000000..d675e6f --- /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 0000000..c0c9b0a --- /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 0000000..62c092a --- /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 0000000..8e8f12a --- /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 0000000..22943e9 --- /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 0000000..9061d48 --- /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 0000000..3d7cca5 --- /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 0000000..2c32531 --- /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 0000000..9a2f897 --- /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 0000000..f96ea0a --- /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 0000000..97f196b --- /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 0000000..f0f6276 --- /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 0000000..84b8447 --- /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 0000000..0ed16b1 --- /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 0000000..45f927c --- /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 0000000..8298d18 --- /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 0000000..4bbaaed --- /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 0000000..d4d87d5 --- /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 0000000..c22ac91 --- /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 0000000..5bff68f --- /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 0000000..4745d9b --- /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 0000000..c0be695 --- /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 0000000..5c633ce --- /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 0000000..35e7c9a --- /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 0000000..fd6f531 --- /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 0000000..62dd305 --- /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 0000000..b608b5f --- /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 0000000..5121b3a --- /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 0000000..0e762ce --- /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 0000000..3fe63c6 --- /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 0000000..94bfb1e --- /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 0000000..937b28a --- /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 0000000..6f7fd73 --- /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 0000000..2f5141a --- /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 0000000..c5d3e15 --- /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 0000000..86186d1 --- /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 0000000..99822f7 --- /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 0000000..1751e1a --- /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 0000000..aeab8eb --- /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 0000000..78d45b7 --- /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 0000000..e03a2be --- /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 0000000..8684f98 --- /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 0000000..b01a984 --- /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 0000000..dc7cf04 --- /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 0000000..d8f5994 --- /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 0000000..cda5618 --- /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 0000000..586c9d3 --- /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 0000000..f6273a8 --- /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 0000000..22f4424 --- /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 0000000..0c6fe8e --- /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 0000000..0b92171 --- /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 0000000..8025c7f --- /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 0000000..20f8049 --- /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 0000000..e4f82bd --- /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 0000000..14278e8 --- /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 0000000..ef7a85a --- /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 0000000..547ec26 --- /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 0000000..c49c1ec --- /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 0000000..a566472 --- /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 0000000..be76261 --- /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 0000000..185a026 --- /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 0000000..5e67a4d --- /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 0000000..abd3347 --- /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 0000000..1a041ac --- /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 0000000..9e280e5 --- /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 0000000..c6e103e --- /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 0000000..7c62ead --- /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 0000000..b037537 --- /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 0000000..a8bb50d --- /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 0000000..e4be9a7 --- /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 0000000..fb69ac9 --- /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 0000000..d37d7bd --- /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 0000000..ac2a713 --- /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 0000000..f60c257 --- /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 0000000..9937325 --- /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 0000000..5f26cce --- /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 0000000..5d48577 --- /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 0000000..7f2a5a1 --- /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 0000000..745b115 --- /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 0000000..452ada7 --- /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 0000000..01962fa --- /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 0000000..ecff84f --- /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 0000000..446c897 --- /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 0000000..dc7ddd4 --- /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 0000000..042132f --- /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 0000000..d69769e --- /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 0000000..87e2013 --- /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 0000000..0699510 --- /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 0000000..286c0aa --- /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 0000000..e1fd36d --- /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 0000000..61ba63c --- /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 0000000..a3da94f --- /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 0000000..520c6a1 --- /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 0000000..19e12d2 --- /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 0000000..afab810 --- /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 0000000..fd9aafd --- /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 0000000..91881cd --- /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 0000000..465fe05 --- /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 0000000..a3603d7 --- /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 0000000..9ac3cbc --- /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 0000000..f3107b7 --- /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 0000000..e96a605 --- /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 0000000..9c59baa --- /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 0000000..6c6b753 --- /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 0000000..4360c64 --- /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 0000000..140b446 --- /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 0000000..55b3f88 --- /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 0000000..f3c8c32 --- /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 0000000..e700653 --- /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 0000000..199b051 --- /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 0000000..3962421 --- /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 0000000..d80a0bf --- /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 0000000..e6e7ead --- /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 0000000..2d7bab7 --- /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 0000000..0e6aebf --- /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 0000000..6c466e4 --- /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 0000000..bc7af57 --- /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 0000000..c05dda2 --- /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 0000000..fd6e209 --- /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 0000000..ccceaa9 --- /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 0000000..9d15257 --- /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 0000000..7b7ebcb --- /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 0000000..d144669 --- /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 0000000..c42f3e2 --- /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 0000000..a9d76e4 --- /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 0000000..ed8186f --- /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 0000000..0b857cf --- /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 0000000..4449e3e --- /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 0000000..93c4566 --- /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 0000000..40187b1 --- /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 0000000..8a3f540 --- /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 0000000..250f46a --- /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 0000000..3437685 --- /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 0000000..1fddf89 --- /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 0000000..fedb672 --- /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 0000000..f071873 --- /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 0000000..304d988 --- /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 0000000..d846811 --- /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 0000000..9cb5725 --- /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 0000000..62200bb --- /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 0000000..1703def --- /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 0000000..0846ceb --- /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 0000000..9f31334 --- /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 0000000..96ae489 --- /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 0000000..163a020 --- /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 0000000..1c818ad --- /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 0000000..1714c7e --- /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 0000000..83dc6da --- /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 0000000..b838ca1 --- /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 0000000..a243b50 --- /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 0000000..d66d09d --- /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 0000000..89b66af --- /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 0000000..bfd2d52 --- /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 0000000..9c60dab --- /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 0000000..0f2595e --- /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 0000000..94d9068 --- /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 0000000..7d514e8 --- /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 0000000..6da3596 --- /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 0000000..d47c62b --- /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 0000000..242143d --- /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 0000000..0f9d117 --- /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/85] 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 0000000..5cc2efc --- /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 0000000..2376ba9 --- /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 0000000..415e130 --- /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 0000000..674d640 --- /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 0000000..12e5464 --- /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 0000000..c1c437a --- /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 0000000..fcd4a80 --- /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 0000000..64a5da3 --- /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 0000000..644aeff --- /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 0000000..b717d7e --- /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 0000000..a8a40a6 --- /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 0000000..1c910b7 --- /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 0000000..9b44e6e --- /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 0000000..fbdf286 --- /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/85] 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 5cc2efc..0000000 --- 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 2376ba9..0000000 --- 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 415e130..0000000 --- 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 674d640..0000000 --- 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 12e5464..0000000 --- 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 c1c437a..0000000 --- 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 fcd4a80..0000000 --- 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 64a5da3..0000000 --- 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 644aeff..0000000 --- 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 b717d7e..0000000 --- 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 a8a40a6..0000000 --- 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 1c910b7..0000000 --- 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 9b44e6e..0000000 --- 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 fbdf286..0000000 --- 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/85] 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/85] 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 0000000..7fa56d2 --- /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 0000000..e0f669f --- /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 0000000..4b8d2d2 --- /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 0000000..41a56f7 --- /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 0000000..fbe7040 --- /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 0000000..e855ba3 --- /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 0000000..98228ad --- /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 0000000..d5aa320 --- /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 0000000..e69dce5 --- /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 0000000..6d467b7 --- /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 0000000..9065d83 --- /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 0000000..2df8354 --- /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 0000000..4e4cfb7 --- /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 0000000..66c3958 --- /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 0000000..7d77810 --- /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 0000000..9687fe7 --- /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 0000000..b2a020a --- /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 0000000..651e58f --- /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 0000000..8a4c3b8 --- /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 0000000..447a8c4 --- /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 0000000..640513f --- /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 0000000..ce07d1d --- /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 0000000..b426e5c --- /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/85] 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 4e4cfb7..43c1ea2 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 66c3958..fffa023 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 651e58f..6cd0bdd 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 8a4c3b8..93fe86b 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 447a8c4..af856df 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 640513f..266ba03 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 ce07d1d..7e403ea 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/85] 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 0000000..b12a228 --- /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 0000000..934cd99 --- /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 0000000..f5df7fa --- /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 0000000..eed2edc --- /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 0000000..4516278 --- /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 0000000..0e521ad --- /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 0000000..4a03a77 --- /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 0000000..a7797a4 --- /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 0000000..d5fbbd9 --- /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 0000000..b15fe6f --- /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 0000000..7aebcaa --- /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 0000000..c982980 --- /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 0000000..3866e04 --- /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 0000000..3490cb3 --- /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 0000000..ee90f1c --- /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 0000000..1473465 --- /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 0000000..1d94c99 --- /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 0000000..1e03d76 --- /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 0000000..db7c629 --- /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 0000000..466335b --- /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 0000000..2e3a1a2 --- /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 0000000..0540a8f --- /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 0000000..ba9ba81 --- /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 0000000..62bed7f --- /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/85] 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 0000000..6c25729 --- /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 0000000..7b42b58 --- /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 0000000..8867b3b --- /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 0000000..4c81d4e --- /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 0000000..9d0c570 --- /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 0000000..b81206d --- /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 0000000..077e04a --- /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 0000000..0a80491 --- /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 0000000..095ec65 --- /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 0000000..c1a571b --- /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 0000000..fe7cbee --- /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 0000000..bbcd565 --- /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 0000000..4db741d --- /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 0000000..8781a1e --- /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 0000000..7f9f79c --- /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 0000000..71ce063 --- /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 0000000..7e78395 --- /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 0000000..79878dd --- /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 0000000..1cd409d --- /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 0000000..b5b1c0e --- /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 0000000..e87522f --- /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 0000000..dde4480 --- /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 0000000..569129e --- /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 0000000..347c05c --- /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 0000000..660d838 --- /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 0000000..b110de8 --- /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 0000000..c3606ac --- /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 0000000..5da86d5 --- /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 0000000..23420fc --- /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 0000000..915108c --- /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 0000000..519d52c --- /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 0000000..ce7ec8a --- /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 0000000..05c1a97 --- /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 0000000..1bb95f3 --- /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 0000000..1a4e1a8 --- /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 0000000..552c68c --- /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 0000000..073ba0e --- /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 0000000..a6ab3bd --- /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 0000000..3ababd7 --- /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 0000000..046c4b5 --- /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 0000000..b87e54e --- /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 0000000..940c916 --- /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 0000000..c9fe690 --- /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 0000000..13df83f --- /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 0000000..321d96a --- /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 0000000..157c6e6 --- /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 0000000..a8dcbba --- /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 0000000..b42a678 --- /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 0000000..5bc9d90 --- /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 0000000..6c0f705 --- /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 0000000..5464f5f --- /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 0000000..9506631 --- /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 0000000..6f097e6 --- /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 0000000..778a85f --- /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 0000000..2dbd8a5 --- /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 0000000..62cf997 --- /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 0000000..199fbc0 --- /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 0000000..35865b9 --- /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 0000000..7e512f1 --- /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 0000000..0376cfe --- /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 0000000..d7f67e7 --- /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 0000000..4ae4c1b --- /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 0000000..897f099 --- /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 0000000..6ea0098 --- /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 0000000..e2bd5d9 --- /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 0000000..b668594 --- /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 0000000..597dfb0 --- /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 0000000..8e01409 --- /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 0000000..da9847d --- /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 0000000..10eb844 --- /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 0000000..42ec092 --- /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 0000000..f6ea36a --- /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 0000000..aec2c3a --- /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 0000000..29cf12f --- /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 0000000..e9859c0 --- /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 0000000..1e27748 --- /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 0000000..dd6be35 --- /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 0000000..014b2de --- /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 0000000..7bf7c27 --- /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 0000000..4c7764e --- /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 0000000..1dc0863 --- /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 0000000..2033d58 --- /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 0000000..3e4e3e8 --- /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 0000000..cfcf306 --- /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 0000000..634d7f1 --- /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 0000000..84f66fb --- /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 0000000..22f09eb --- /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 0000000..ea8a888 --- /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 0000000..d62c4d8 --- /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 0000000..4d86473 --- /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 0000000..66abaac --- /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 0000000..41a95c9 --- /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 0000000..2745ab1 --- /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 0000000..98f257b --- /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 0000000..2298b55 --- /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 0000000..17b1407 --- /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 0000000..e7c6758 --- /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 0000000..566ebc0 --- /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 0000000..61f662a --- /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 0000000..dd3138a --- /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 0000000..ce61267 --- /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 0000000..b40c37f --- /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 0000000..ef43ebc --- /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 0000000..84a0971 --- /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 0000000..be5b130 --- /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 0000000..5545bba --- /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 0000000..e70f3b4 --- /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 0000000..2cd00b9 --- /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 0000000..80c04f0 --- /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 0000000..62c5c6d --- /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 0000000..c2f6517 --- /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 0000000..97e2f63 --- /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 0000000..af51fdb --- /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 0000000..948291a --- /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 0000000..ff760fd --- /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 0000000..8623565 --- /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 0000000..84936da --- /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 0000000..9dd2613 --- /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 0000000..e16081b --- /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 0000000..d506b62 --- /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 0000000..45cfa45 --- /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 0000000..54c4423 --- /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 0000000..634c26a --- /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 0000000..6185b26 --- /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 0000000..03eb033 --- /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 0000000..81864e2 --- /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 0000000..5fb1cbf --- /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 0000000..2279635 --- /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 0000000..0c98a17 --- /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 0000000..50b3b8c --- /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 0000000..154e4a7 --- /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 0000000..2b51ba0 --- /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 0000000..36ac765 --- /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 0000000..14d40cf --- /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 0000000..b7eae96 --- /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 0000000..8c5162d --- /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 0000000..e0f97e2 --- /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 0000000..4ea2016 --- /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 0000000..cec800b --- /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 0000000..d99f243 --- /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 0000000..34c8373 --- /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 0000000..2681664 --- /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 0000000..404c0b3 --- /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 0000000..8dcc92c --- /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 0000000..ea37dab --- /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 0000000..63bd18a --- /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 0000000..bf5d3f1 --- /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 0000000..77e3945 --- /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 0000000..a3db68e --- /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 0000000..31752c1 --- /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 0000000..5976cb2 --- /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 0000000..870fabf --- /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 0000000..0226cb9 --- /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 0000000..fa91181 --- /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 0000000..6750063 --- /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 0000000..adba265 --- /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 0000000..49bb0eb --- /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 0000000..1c25457 --- /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 0000000..0f6a125 --- /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 0000000..48f3a94 --- /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 0000000..8380e16 --- /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 0000000..95908f0 --- /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 0000000..2ebf137 --- /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 0000000..5d23b3c --- /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 0000000..7332ce9 --- /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 0000000..7248767 --- /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 0000000..ba53360 --- /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 0000000..07c7706 --- /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 0000000..2992af8 --- /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 0000000..0e5bc8d --- /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 0000000..bacaaac --- /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 0000000..c099308 --- /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 0000000..ed369e6 --- /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 0000000..f06aa2c --- /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 0000000..758d8bd --- /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 0000000..abef7be --- /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 0000000..600ce8c --- /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 0000000..dce3dff --- /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 0000000..f5d3f15 --- /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 0000000..203a5b5 --- /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 0000000..6fd012f --- /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 0000000..fa3bf91 --- /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 0000000..f0c698f --- /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 0000000..eccaacd --- /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 0000000..9fd40de --- /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 0000000..f28cdbc --- /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 0000000..dbd076a --- /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 0000000..2a25166 --- /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 0000000..449f26e --- /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 0000000..4536d2f --- /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 0000000..e6a1fdd --- /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 0000000..019cd0d --- /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 0000000..a676d42 --- /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 0000000..156e9dc --- /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 0000000..0fcae67 --- /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 0000000..fffeb69 --- /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 0000000..8efa2f6 --- /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 0000000..9026ff0 --- /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 0000000..9423d00 --- /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 0000000..b4bd37f --- /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 0000000..734a47d --- /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 0000000..7ae03c8 --- /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 0000000..269fa61 --- /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 0000000..62fbdfd --- /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 0000000..9c5d30b --- /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 0000000..3b4c088 --- /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 0000000..1b13b17 --- /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 0000000..5ef2d80 --- /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 0000000..d2c0579 --- /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 0000000..ef1d204 --- /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 0000000..16b0c4e --- /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 0000000..6d68b17 --- /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 0000000..5e953eb --- /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 0000000..bf7071f --- /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 0000000..356a547 --- /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 0000000..fcefb49 --- /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 0000000..97ea846 --- /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 0000000..9d46822 --- /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 0000000..fc50e40 --- /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 0000000..a6e8aa7 --- /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 0000000..c8bb251 --- /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 0000000..bf6f36e --- /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 0000000..aefd1c8 --- /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 0000000..73d179c --- /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 0000000..c30e6b2 --- /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 0000000..4e7dc74 --- /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 0000000..68fafff --- /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 0000000..da4fb9a --- /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 0000000..559a1ae --- /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 0000000..b45310e --- /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 0000000..bbd39fb --- /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 0000000..1008aa4 --- /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 0000000..f18dd30 --- /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 0000000..f8ff88d --- /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 0000000..92983bd --- /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 0000000..64357e0 --- /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 0000000..9048373 --- /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 0000000..94d2eaf --- /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 0000000..882a8c1 --- /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 0000000..fa9760f --- /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 0000000..997413a --- /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 0000000..6f8adb6 --- /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 0000000..e14a735 --- /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 0000000..c9dbc58 --- /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 0000000..0c77456 --- /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 0000000..77b786c --- /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 0000000..468ff65 --- /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 0000000..b430930 --- /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 0000000..545ce25 --- /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 0000000..5e74f7b --- /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 0000000..c169843 --- /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 0000000..2a9edfa --- /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 0000000..49a1e48 --- /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 0000000..126eb3b --- /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 0000000..3fd5ef6 --- /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 0000000..4bc3c2c --- /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 0000000..8c1ce91 --- /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 0000000..f7b7cdf --- /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 0000000..53df796 --- /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 0000000..a078dc2 --- /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/85] 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 0000000..6a2777f --- /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 0000000..88742cd --- /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 0000000..30ed4f1 --- /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 0000000..5be0425 --- /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 0000000..97409ec --- /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 0000000..bc82cd6 --- /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 0000000..be5236f --- /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 0000000..12b44c9 --- /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 0000000..c5303d0 --- /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 0000000..596a897 --- /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 0000000..9038262 --- /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 0000000..20c18f6 --- /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 0000000..e93a91e --- /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 0000000..c0b5d1c --- /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 0000000..e465096 --- /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 0000000..195181e --- /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 0000000..50595c8 --- /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 0000000..01a2427 --- /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 0000000..a588aee --- /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 0000000..520e9bb --- /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 0000000..c33a922 --- /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 0000000..a07f910 --- /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 0000000..51455e8 --- /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 0000000..fcbcb1b --- /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 0000000..44212fc --- /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 0000000..7d1c1c6 --- /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 0000000..48c8349 --- /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 0000000..ab3e333 --- /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 0000000..233a6e1 --- /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 0000000..c651da0 --- /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 0000000..19b1b13 --- /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 0000000..e2ff07d --- /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 0000000..9f51ff6 --- /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 0000000..e5e570f --- /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 0000000..e8470f7 --- /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 0000000..cd2f944 --- /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 0000000..8ebb401 --- /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 0000000..c2db4dd --- /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 0000000..4d2e0e4 --- /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 0000000..1179a81 --- /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 0000000..624d13b --- /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 0000000..1bfca3a --- /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 0000000..ca99218 --- /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 0000000..61c5183 --- /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 0000000..52d574a --- /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 0000000..9cc8125 --- /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 0000000..659530b --- /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 0000000..35d81a6 --- /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 0000000..905837c --- /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 0000000..c1e2fc5 --- /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 0000000..fc13c1c --- /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 0000000..dd0b293 --- /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 0000000..1ab2f64 --- /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 0000000..0ff7a07 --- /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 0000000..9bb8ad4 --- /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 0000000..10602e9 --- /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 0000000..c816208 --- /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 0000000..6a0b7d0 --- /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 0000000..f4b1ee6 --- /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 0000000..4dcd7ca --- /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 0000000..f52af50 --- /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 0000000..03b5b8d --- /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 0000000..e4b850a --- /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 0000000..ee3f5bd --- /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 0000000..94d854e --- /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 0000000..6c5ac7a --- /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 0000000..a44c23a --- /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 0000000..9358981 --- /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 0000000..f518599 --- /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 0000000..e88027a --- /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 0000000..fd59ac0 --- /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 0000000..e25cf3e --- /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 0000000..981494b --- /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 0000000..2c4836e --- /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 0000000..9049367 --- /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 0000000..a99101d --- /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 0000000..6fd755c --- /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 0000000..a54e069 --- /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 0000000..ec343eb --- /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 0000000..c22004f --- /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 0000000..3be3aa2 --- /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 0000000..f58e532 --- /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 0000000..a9cd275 --- /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 0000000..56f630b --- /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 0000000..538688a --- /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 0000000..3a6a56b --- /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 0000000..6bba558 --- /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 0000000..01ace1b --- /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 0000000..b292dcc --- /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 0000000..7d516df --- /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 0000000..e185d84 --- /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 0000000..a73b2e6 --- /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 0000000..efa9096 --- /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 0000000..2d46cde --- /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 0000000..34a57cf --- /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 0000000..480e688 --- /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 0000000..dae32ea --- /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 0000000..c286a24 --- /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 0000000..d7acc1c --- /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 0000000..b537aaf --- /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 0000000..479092a --- /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 0000000..1b1b28f --- /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 0000000..35b68af --- /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 0000000..8e908a8 --- /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 0000000..38e6c06 --- /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 0000000..6341909 --- /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 0000000..1f55460 --- /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 0000000..df44993 --- /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 0000000..5c108de --- /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 0000000..7776c00 --- /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 0000000..31a957b --- /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 0000000..87e1e29 --- /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 0000000..9e56079 --- /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 0000000..68df597 --- /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 0000000..873b52d --- /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 0000000..2717fa8 --- /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 0000000..61b0f71 --- /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 0000000..5363de1 --- /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 0000000..e1da6c0 --- /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 0000000..315b484 --- /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 0000000..1fb0ce6 --- /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 0000000..2b22498 --- /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 0000000..43c22e8 --- /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 0000000..a8bf73e --- /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 0000000..b102f0c --- /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 0000000..13ec864 --- /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 0000000..0611f34 --- /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 0000000..71c7e4e --- /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 0000000..e1882af --- /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 0000000..a011d39 --- /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 0000000..abd31a8 --- /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 0000000..5265778 --- /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 0000000..560f96f --- /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 0000000..cb2f089 --- /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 0000000..b32e632 --- /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 0000000..9488ef5 --- /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 0000000..ad3408f --- /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 0000000..f85e98a --- /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 0000000..2bfe020 --- /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 0000000..b4d2711 --- /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 0000000..f06b518 --- /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 0000000..4c77cc1 --- /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 0000000..b56c83a --- /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 0000000..3481ce4 --- /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 0000000..aa7170d --- /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 0000000..95e13c0 --- /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 0000000..62e1104 --- /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 0000000..48eeff4 --- /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 0000000..8159572 --- /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 0000000..f9f0549 --- /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 0000000..9e8288f --- /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 0000000..d83b491 --- /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 0000000..a1ae120 --- /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 0000000..11e24e0 --- /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 0000000..aff534e --- /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 0000000..ba64c54 --- /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 0000000..725fd92 --- /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 0000000..43b623f --- /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 0000000..096661c --- /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 0000000..0106462 --- /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 0000000..87b4f5d --- /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 0000000..8ab43cf --- /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 0000000..3b3f5ab --- /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 0000000..ea7308f --- /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 0000000..cf8c3a1 --- /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 0000000..b71381e --- /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 0000000..69a427d --- /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 0000000..1abcaa8 --- /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 0000000..84d64a4 --- /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 0000000..dbf0ab8 --- /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 0000000..40b1fef --- /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 0000000..3e9ef79 --- /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 0000000..9996e46 --- /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 0000000..e5adc79 --- /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 0000000..e58c954 --- /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 0000000..15f874d --- /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 0000000..bd6158c --- /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 0000000..f8f1418 --- /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 0000000..fc6d287 --- /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 0000000..b2d7f31 --- /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 0000000..370b889 --- /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 0000000..9e87fdb --- /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 0000000..db22f1a --- /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 0000000..4bf6cd7 --- /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 0000000..04d4b5a --- /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 0000000..7efef39 --- /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 0000000..543d04f --- /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 0000000..f54f93e --- /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 0000000..f9de2af --- /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 0000000..a8a54e8 --- /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 0000000..35bfbc7 --- /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 0000000..4196ca7 --- /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 0000000..bb1ca2a --- /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 0000000..ea14d80 --- /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 0000000..9e27dc2 --- /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 0000000..0900095 --- /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 0000000..a79c25e --- /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 0000000..3d6dbb1 --- /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 0000000..40b0728 --- /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 0000000..f0113dd --- /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 0000000..eff18d7 --- /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 0000000..828ac6f --- /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 0000000..a8ca211 --- /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 0000000..bb53472 --- /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 0000000..8e9614f --- /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 0000000..1600327 --- /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 0000000..0c28ff4 --- /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 0000000..a7a5f34 --- /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 0000000..b6a71d7 --- /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 0000000..68136cc --- /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 0000000..c2866f9 --- /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 0000000..e68d80e --- /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 0000000..0041840 --- /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 0000000..000f9e0 --- /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 0000000..4930eb7 --- /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 0000000..2391adb --- /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 0000000..e950307 --- /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 0000000..6a6c42f --- /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 0000000..9d12b90 --- /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 0000000..5a69e5a --- /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 0000000..e18aa63 --- /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 0000000..f953aa7 --- /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 0000000..bf1bff4 --- /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 0000000..a8b1e6b --- /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 0000000..7e32c8f --- /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 0000000..a4dd33c --- /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 0000000..4290381 --- /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 0000000..de6d28c --- /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 0000000..ca3c220 --- /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 0000000..45466cc --- /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 0000000..cee60ea --- /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 0000000..24f22ea --- /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 0000000..3bbc094 --- /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 0000000..a5cce0c --- /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 0000000..12df13d --- /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 0000000..0cbe6d3 --- /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 0000000..a70cc45 --- /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 0000000..af7c0dd --- /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 0000000..e6f7a8e --- /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 0000000..1246cbb --- /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 0000000..2c8543d --- /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 0000000..b946013 --- /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 0000000..b1d6572 --- /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 0000000..df046ca --- /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 0000000..afd4ec0 --- /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 0000000..54d2c99 --- /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 0000000..aa63d49 --- /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 0000000..177288a --- /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 0000000..c723473 --- /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 0000000..a2f8977 --- /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 0000000..7b9dd59 --- /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 0000000..229dd6b --- /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 0000000..d47205a --- /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 0000000..78fdb0c --- /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 0000000..2c5950c --- /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 0000000..7cf37a5 --- /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 0000000..4b5df73 --- /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 0000000..9caa21a --- /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 0000000..72a92e5 --- /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 0000000..a7531ff --- /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/85] 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 0000000..5faee83 --- /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 0000000..2cfa17d --- /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 0000000..7834e09 --- /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 0000000..5053401 --- /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 0000000..e329ba8 --- /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 0000000..761d068 --- /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 0000000..5c7618e --- /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 0000000..6fc4f4d --- /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 0000000..74f80db --- /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 0000000..f1eb487 --- /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 0000000..083ed13 --- /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 0000000..aa4f731 --- /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 0000000..785303b --- /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 0000000..42b444b --- /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 0000000..9d926ea --- /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 0000000..c4a1a57 --- /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 0000000..f19cc81 --- /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 0000000..82acf93 --- /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/85] 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 0000000..bda7770 --- /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 0000000..0671731 --- /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 0000000..19355c9 --- /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 0000000..ea2704b --- /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 0000000..baa0ba2 --- /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 0000000..306f3db --- /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 0000000..510feca --- /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 0000000..1c3bc56 --- /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 0000000..904ec17 --- /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 0000000..07e1851 --- /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 0000000..9d9dc97 --- /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 0000000..b8d8db6 --- /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 0000000..612e856 --- /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 0000000..45bf397 --- /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 0000000..aaf4542 --- /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 0000000..275f405 --- /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 0000000..b8d0b28 --- /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 0000000..f2cd982 --- /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 0000000..e22cac1 --- /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 0000000..1907bd4 --- /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/85] 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 0000000..a9f9f13 --- /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 0000000..b699d21 --- /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 0000000..4ef8595 --- /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 0000000..d2b3c39 --- /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 0000000..321854c --- /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 0000000..7c03cdd --- /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 0000000..10a237f --- /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 0000000..b32385b --- /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 0000000..4f68302 --- /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 0000000..58bbc89 --- /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 0000000..5148721 --- /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 0000000..8fb05b2 --- /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 0000000..aa810dc --- /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 0000000..acbd56b --- /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 0000000..ad8b42b --- /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 0000000..9dde771 --- /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 0000000..d1eeefb --- /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 0000000..ee9d5ff --- /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 0000000..493b089 --- /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 0000000..875c65d --- /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 0000000..bfb1e15 --- /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 0000000..6ece016 --- /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 0000000..3af3a19 --- /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 0000000..ed50994 --- /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 0000000..dfcf07d --- /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 0000000..8eb3c56 --- /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 0000000..04ee605 --- /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 0000000..de6b7fd --- /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 0000000..d5c9a6d --- /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 0000000..d7ff394 --- /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 0000000..5a837ca --- /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 0000000..9f03e5d --- /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 0000000..cedcb9f --- /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 0000000..32e6cfb --- /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 0000000..5a431e0 --- /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 0000000..5dcaef6 --- /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 0000000..085db77 --- /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 0000000..07399af --- /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 0000000..c1a3ec3 --- /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 0000000..064dfc3 --- /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 0000000..5a111f1 --- /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 0000000..e1f0624 --- /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 0000000..0cb879d --- /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 0000000..6c11846 --- /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 0000000..6979086 --- /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 0000000..705f69b --- /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 0000000..4d04389 --- /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 0000000..c3f989e --- /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 0000000..d90eaf5 --- /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 0000000..a6cd13d --- /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 0000000..695af42 --- /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 0000000..21bf227 --- /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 0000000..0c1de8e --- /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 0000000..8472c56 --- /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 0000000..e2676dc --- /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 0000000..1007d2f --- /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 0000000..225fa13 --- /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 0000000..e0e0f48 --- /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 0000000..4b7fe9b --- /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 0000000..871f216 --- /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 0000000..b51f823 --- /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 0000000..1a370a7 --- /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 0000000..a49fc97 --- /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 0000000..1abc72f --- /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 0000000..35f233c --- /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 0000000..1363649 --- /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 0000000..137676a --- /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 0000000..d96f5f5 --- /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 0000000..fb3fd73 --- /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 0000000..e02fb35 --- /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 0000000..24416f3 --- /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/85] 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 0000000..1a3946b --- /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 0000000..e4d287e --- /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 0000000..3e32aee --- /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 0000000..d05926e --- /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 0000000..da560b1 --- /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 0000000..1f723ab --- /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 0000000..72a2131 --- /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 0000000..9676e15 --- /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 0000000..7b290d7 --- /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 0000000..f658e43 --- /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 0000000..b3b372a --- /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 0000000..bc371d3 --- /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 0000000..583d2d8 --- /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 0000000..97e3f47 --- /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 0000000..6103fdf --- /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 0000000..1eb5376 --- /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 0000000..d213640 --- /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 0000000..c5d0c91 --- /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 0000000..3cb6c37 --- /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 0000000..90340b2 --- /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 0000000..e5dfa32 --- /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 0000000..bc760fa --- /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 0000000..01bc897 --- /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 0000000..e623994 --- /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 0000000..09705d5 --- /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 0000000..fe60393 --- /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 0000000..ba1fa23 --- /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 0000000..fb7c1c0 --- /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 0000000..c3243d1 --- /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 0000000..1e92791 --- /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 0000000..966b88d --- /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 0000000..22580c5 --- /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 0000000..24223f2 --- /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 0000000..8b32fad --- /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 0000000..5e75e9b --- /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 0000000..abbede3 --- /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 0000000..21b3186 --- /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 0000000..868901b --- /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 0000000..09b014d --- /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 0000000..ad6089f --- /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 0000000..2919372 --- /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 0000000..49afa0d --- /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 0000000..9c17fc9 --- /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 0000000..b2c6570 --- /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 0000000..5e85fdc --- /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 0000000..26aaabc --- /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 0000000..b92ed85 --- /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 0000000..6378a04 --- /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 0000000..fe62a63 --- /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 0000000..623dcb4 --- /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 0000000..d4f3df6 --- /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 0000000..51eae07 --- /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 0000000..15b2360 --- /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 0000000..8e6e394 --- /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 0000000..c7913be --- /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 0000000..41d848b --- /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 0000000..9a585d1 --- /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 0000000..0ebe4c5 --- /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 0000000..0f4dec2 --- /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 0000000..b7130ec --- /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 0000000..cccbd1a --- /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 0000000..e8b9362 --- /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 0000000..85aa538 --- /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 0000000..6eaff9c --- /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 0000000..3f2193f --- /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 0000000..d22b64e --- /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 0000000..637afe4 --- /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 0000000..7458782 --- /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 0000000..057e9e4 --- /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 0000000..0d08cb6 --- /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 0000000..7db27e3 --- /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 0000000..0ef1a45 --- /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 0000000..d570659 --- /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 0000000..374ff52 --- /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 0000000..6fbed3b --- /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 0000000..c8c697e --- /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 0000000..7bd399d --- /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 0000000..cf80180 --- /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 0000000..0885a14 --- /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 0000000..484aa35 --- /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 0000000..148ac9e --- /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 0000000..84cc0b1 --- /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 0000000..2ee7f7a --- /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 0000000..e895ef7 --- /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 0000000..71926d8 --- /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 0000000..da9128b --- /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 0000000..ef05380 --- /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 0000000..b2aac2c --- /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 0000000..74fc7a0 --- /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 0000000..c7dedef --- /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 0000000..ce5639f --- /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 0000000..71b4d77 --- /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 0000000..1c2e11a --- /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 0000000..d06295d --- /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 0000000..2fb83e6 --- /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 0000000..8ced7e6 --- /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 0000000..3f25b7d --- /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 0000000..8a70181 --- /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 0000000..7ce6349 --- /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 0000000..730fbf5 --- /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 0000000..2232bde --- /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 0000000..d5d5ec9 --- /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 0000000..de4f15a --- /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 0000000..2700538 --- /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 0000000..a934afd --- /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 0000000..8cd3748 --- /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 0000000..8a0c553 --- /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 0000000..c232adb --- /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 0000000..68a1b8e --- /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 0000000..6923bd3 --- /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 0000000..ef883fa --- /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 0000000..cc12193 --- /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 0000000..1f3d5e2 --- /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 0000000..c65da3e --- /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 0000000..40d116f --- /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 0000000..20ad59f --- /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 0000000..33fbf4c --- /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 0000000..1e1a33e --- /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 0000000..c59c9b7 --- /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 0000000..ae1ecd0 --- /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 0000000..b46d14f --- /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 0000000..c78ec9d --- /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 0000000..00ebf0f --- /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 0000000..ab08be1 --- /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 0000000..36e5728 --- /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 0000000..878172d --- /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 0000000..3c0658d --- /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 0000000..471b856 --- /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 0000000..2f326d1 --- /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 0000000..2c3d5b3 --- /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 0000000..0647649 --- /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 0000000..8bc3342 --- /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 0000000..9f81032 --- /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 0000000..5ed78f3 --- /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 0000000..1f52c39 --- /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 0000000..c430f12 --- /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 0000000..4ac376f --- /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 0000000..973ab32 --- /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 0000000..5ba4afb --- /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 0000000..8908cdf --- /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 0000000..ec33d6c --- /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 0000000..883529b --- /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 0000000..636f7a5 --- /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 0000000..3582956 --- /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 0000000..f042e75 --- /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 0000000..32016d6 --- /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 0000000..2a6560b --- /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 0000000..7d8fa6d --- /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 0000000..fe6c81a --- /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 0000000..d5fa27a --- /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 0000000..9a4a185 --- /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 0000000..3a829fa --- /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 0000000..ec48f3d --- /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 0000000..b7df375 --- /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 0000000..2b02ab8 --- /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 0000000..8fa523f --- /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 0000000..31c2640 --- /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 0000000..13bce63 --- /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 0000000..e7f7f15 --- /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 0000000..2348a4d --- /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 0000000..7f8d54e --- /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 0000000..39a6c24 --- /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 0000000..cc15354 --- /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 0000000..c6f4261 --- /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 0000000..0e3c90a --- /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 0000000..e2b690b --- /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 0000000..24e8b6a --- /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 0000000..ffc8166 --- /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 0000000..098601b --- /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 0000000..e53f600 --- /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 0000000..dfdeec7 --- /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 0000000..8774eec --- /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 0000000..e3a5705 --- /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 0000000..e78e843 --- /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 0000000..9b7212e --- /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 0000000..a8531a5 --- /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 0000000..61dc5a8 --- /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 0000000..f360981 --- /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 0000000..122dcf5 --- /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 0000000..83fba8f --- /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 0000000..4809a54 --- /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 0000000..a2decc8 --- /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 0000000..71eaf0e --- /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 0000000..d50e209 --- /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 0000000..bec6e46 --- /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 0000000..cbe9c95 --- /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 0000000..6a1221c --- /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 0000000..0bbcb60 --- /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 0000000..cc1ef24 --- /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 0000000..e9b5c8f --- /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 0000000..c5f77cc --- /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 0000000..c2006b8 --- /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 0000000..e9340f2 --- /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 0000000..6b45b43 --- /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 0000000..1f6ac13 --- /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 0000000..5661d3f --- /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 0000000..cfa2bc5 --- /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 0000000..c8ea7a6 --- /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 0000000..e9a98f5 --- /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 0000000..0ac2629 --- /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 0000000..83d9d1a --- /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 0000000..7f22714 --- /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 0000000..d0959a8 --- /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 0000000..6dba23b --- /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 0000000..6f78575 --- /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 0000000..ced71ed --- /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 0000000..032ed8d --- /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 0000000..0481771 --- /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 0000000..550f16d --- /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 0000000..561650b --- /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 0000000..412cd9f --- /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 0000000..b9b2663 --- /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 0000000..1cdcb4c --- /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 0000000..436b1ca --- /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 0000000..17e4ef7 --- /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 0000000..4ae0ba8 --- /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 0000000..13d53fb --- /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 0000000..5e41f07 --- /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 0000000..f9b2354 --- /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/85] 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 0000000..2d26baa --- /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 0000000..f6e1d87 --- /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 0000000..6e6ad61 --- /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 0000000..89efebd --- /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 0000000..0f3f6fd --- /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 0000000..76ce26e --- /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 0000000..32e9471 --- /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 0000000..e311ddc --- /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 0000000..b177730 --- /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 0000000..7b3376a --- /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 0000000..d84218f --- /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 0000000..1c26122 --- /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 0000000..60aedee --- /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 0000000..0ef14ac --- /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 0000000..b940487 --- /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 0000000..64b9e38 --- /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 0000000..25a0cea --- /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 0000000..8560449 --- /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 0000000..65153e5 --- /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 0000000..1bebbba --- /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 0000000..d32cc7b --- /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 0000000..29dc703 --- /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 0000000..8c1d192 --- /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 0000000..9b300e8 --- /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 0000000..8ffdc5d --- /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 0000000..24368f8 --- /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 0000000..ffd4dcd --- /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 0000000..4e2f3d7 --- /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 0000000..60f5255 --- /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 0000000..33f47a2 --- /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 0000000..e5d935a --- /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 0000000..5de39d6 --- /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 0000000..4b7e476 --- /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 0000000..a81fd75 --- /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 0000000..7b82426 --- /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 0000000..12dbe59 --- /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 0000000..0532467 --- /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 0000000..cd10de2 --- /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 0000000..0ffcf6d --- /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 0000000..7e11891 --- /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 0000000..7736a96 --- /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 0000000..2a3572e --- /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 0000000..5b30081 --- /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 0000000..699e19b --- /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 0000000..e2b3afb --- /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 0000000..8873acb --- /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 0000000..86b028e --- /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 0000000..c92efc3 --- /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 0000000..4679f1a --- /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 0000000..33a211c --- /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 0000000..1c7d8ac --- /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 0000000..851760a --- /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 0000000..d0da47d --- /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 0000000..0d0f72a --- /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/85] 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 1c7d8ac..a4a0f02 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 851760a..03070e3 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 d0da47d..4d4c162 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 0d0f72a..82267d1 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/85] 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 0000000..9b4d3fa --- /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 0000000..d40f535 --- /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 0000000..d8d0269 --- /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 0000000..d01fad6 --- /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 0000000..7d4d457 --- /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 0000000..f288423 --- /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 0000000..f12d55e --- /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 0000000..c428a61 --- /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 0000000..a5f577c --- /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 0000000..b63c6e7 --- /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 0000000..442a068 --- /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 0000000..11461ee --- /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 0000000..a68a5c1 --- /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 0000000..b56c626 --- /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 0000000..a27910b --- /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 0000000..96d4bb6 --- /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 0000000..a61cc2a --- /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 0000000..24e6025 --- /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 0000000..9d30278 --- /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 0000000..882da8e --- /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 0000000..b73e229 --- /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 0000000..647c379 --- /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 0000000..38fa59c --- /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 0000000..75ffc42 --- /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 0000000..7f4778e --- /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 0000000..9fe8fc5 --- /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 0000000..d5bb2dc --- /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 0000000..8954630 --- /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 0000000..f3176e8 --- /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 0000000..407bf7e --- /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 0000000..b8e5be1 --- /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 0000000..5749771 --- /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 0000000..1e25455 --- /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 0000000..c72c12c --- /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 0000000..b0d9c0a --- /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 0000000..a535879 --- /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 0000000..c515fb8 --- /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 0000000..620bf3e --- /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 0000000..f52b216 --- /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 0000000..53a688a --- /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 0000000..18e9f4a --- /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 0000000..77570cb --- /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 0000000..69dc7ce --- /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 0000000..a5ea77c --- /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 0000000..1e4cd9e --- /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 0000000..dbc07ca --- /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 0000000..7703083 --- /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 0000000..3ddbcde --- /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 0000000..9b7e3bc --- /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 0000000..d1d41bc --- /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 0000000..60db8f3 --- /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 0000000..cdc8725 --- /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 0000000..23f8fb0 --- /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 0000000..6c37e50 --- /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 0000000..69bde84 --- /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 0000000..6e11290 --- /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 0000000..98b9db1 --- /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 0000000..239313a --- /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 0000000..cc87325 --- /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 0000000..63388d2 --- /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 0000000..f7a854c --- /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 0000000..fef3470 --- /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 0000000..7fe3a72 --- /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 0000000..8dc29d8 --- /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 0000000..1537394 --- /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 0000000..9a8202d --- /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 0000000..7fe6d84 --- /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 0000000..f822ce1 --- /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 0000000..27097f9 --- /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 0000000..347c50f --- /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 0000000..dee0547 --- /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 0000000..064bcd4 --- /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 0000000..a34abc1 --- /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 0000000..8fce445 --- /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 0000000..781eb26 --- /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 0000000..9f0f5ca --- /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 0000000..314c4d6 --- /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 0000000..9565e9b --- /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 0000000..a883c5e --- /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 0000000..21a52a5 --- /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 0000000..514387a --- /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/85] 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 0000000..e498e63 --- /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 0000000..095e846 --- /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 0000000..1039266 --- /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 0000000..0be6231 --- /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 0000000..eecd840 --- /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 0000000..a983871 --- /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 0000000..6419736 --- /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 0000000..aef0dae --- /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 0000000..a0e8d3a --- /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 0000000..9ce4c0f --- /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 0000000..d9d3210 --- /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 0000000..464e0c1 --- /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 0000000..75f0cab --- /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 0000000..582dc4f --- /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 0000000..cba4ce3 --- /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 0000000..ce2ccc6 --- /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 0000000..278b290 --- /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 0000000..cd1a426 --- /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 0000000..4bfadeb --- /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 0000000..a25ff67 --- /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 0000000..3500037 --- /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 0000000..7eff242 --- /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 0000000..98c17d3 --- /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 0000000..356a4ab --- /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 0000000..c4048bf --- /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 0000000..a9efcc8 --- /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 0000000..ae38019 --- /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 0000000..78a3592 --- /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 0000000..423ec07 --- /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 0000000..4749e17 --- /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 0000000..8bdfbb8 --- /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 0000000..54a2c4d --- /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 0000000..299ff3e --- /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 0000000..d8754fb --- /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 0000000..8c84769 --- /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 0000000..b7804ad --- /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 0000000..a04f729 --- /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 0000000..e6e128a --- /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 0000000..68ec6c0 --- /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 0000000..4bc4ab0 --- /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 0000000..c4724a6 --- /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 0000000..dccd9ab --- /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 0000000..9e9afe2 --- /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 0000000..e098e30 --- /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 0000000..7ea9359 --- /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 0000000..39362c7 --- /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 0000000..42d9147 --- /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 0000000..19418ed --- /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 0000000..e2533f9 --- /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 0000000..8b59dc6 --- /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 0000000..48601b3 --- /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 0000000..cb2dc14 --- /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 0000000..7017499 --- /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 0000000..a426c65 --- /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 0000000..ad602cd --- /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 0000000..57f7953 --- /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 0000000..15b1523 --- /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 0000000..6d0bb6d --- /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 0000000..84c922c --- /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 0000000..9c3784d --- /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 0000000..c106ed4 --- /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 0000000..b3d0a33 --- /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 0000000..449cf24 --- /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 0000000..6963f70 --- /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 0000000..46b5b21 --- /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 0000000..88f40cc --- /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 0000000..6619767 --- /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 0000000..f4943e0 --- /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 0000000..0be967b --- /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 0000000..86a2140 --- /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 0000000..87a86bc --- /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 0000000..87aec8c --- /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 0000000..5ba1f7a --- /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 0000000..4ea2fec --- /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 0000000..94a39f4 --- /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 0000000..df82e6d --- /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 0000000..01c9ee6 --- /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 0000000..d6e37dc --- /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 0000000..28b6708 --- /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 0000000..0c922dc --- /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 0000000..3026703 --- /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 0000000..9e7c296 --- /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 0000000..e99efb2 --- /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 0000000..16a9c31 --- /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 0000000..bde832b --- /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 0000000..48a716f --- /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 0000000..11a7bff --- /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 0000000..52033f2 --- /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 0000000..60700f3 --- /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 0000000..7c8f9c5 --- /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 0000000..eaf0d96 --- /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 0000000..41efc2c --- /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 0000000..03c50f0 --- /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 0000000..c60e7e0 --- /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 0000000..39235ff --- /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 0000000..fe80670 --- /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 0000000..2682078 --- /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 0000000..806c369 --- /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 0000000..d272653 --- /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 0000000..4b0f3c7 --- /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 0000000..d9e9332 --- /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 0000000..910b395 --- /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 0000000..86c1ad5 --- /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 0000000..9d50717 --- /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 0000000..1d1f4ec --- /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 0000000..7f38988 --- /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 0000000..36886c5 --- /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 0000000..92ec274 --- /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 0000000..c09d900 --- /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 0000000..7e91802 --- /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 0000000..c195236 --- /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 0000000..469a2a2 --- /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 0000000..a5468ab --- /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 0000000..e761589 --- /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 0000000..8151566 --- /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 0000000..31afc9a --- /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 0000000..a734cf7 --- /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 0000000..ecdad69 --- /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 0000000..d82faf5 --- /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 0000000..992d0ee --- /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 0000000..6228d92 --- /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 0000000..547d1b7 --- /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 0000000..ce1ceff --- /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 0000000..79fd217 --- /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 0000000..8fa8f8d --- /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 0000000..7677a82 --- /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 0000000..c931523 --- /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 0000000..7cafe9f --- /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 0000000..12c4798 --- /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 0000000..8c54e2e --- /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 0000000..c602c96 --- /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 0000000..7316356 --- /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 0000000..ab06ab6 --- /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 0000000..4ee963f --- /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 0000000..7a2a79c --- /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 0000000..7072eeb --- /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 0000000..11ee50d --- /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 0000000..3b69acb --- /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 0000000..6b6f5f9 --- /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 0000000..702f9e7 --- /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 0000000..aee5fe3 --- /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 0000000..03f875c --- /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 0000000..0d83a65 --- /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 0000000..4e60f1d --- /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 0000000..2b30e79 --- /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 0000000..094a1e4 --- /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 0000000..c17c99a --- /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 0000000..36e0e57 --- /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 0000000..7b19517 --- /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 0000000..651e49e --- /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 0000000..d72c585 --- /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 0000000..28fa8e1 --- /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 0000000..307d2ac --- /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/85] 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 41efc2c..ccf1dc6 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/85] 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 0000000..e94ce11 --- /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 0000000..587cfca --- /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 0000000..5c891e2 --- /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 0000000..09d90b2 --- /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 0000000..51e0477 --- /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 0000000..934d356 --- /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 0000000..56bbb9d --- /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 0000000..49eaf28 --- /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 0000000..7a77812 --- /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 0000000..4847b88 --- /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 0000000..b8c4247 --- /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 0000000..71b3232 --- /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 0000000..b02e04a --- /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 0000000..9a1c627 --- /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 0000000..7614502 --- /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 0000000..4a5fa63 --- /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 0000000..6ea53b0 --- /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 0000000..73fde08 --- /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 0000000..24a3df9 --- /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 0000000..5f42cae --- /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 0000000..fc22f08 --- /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 0000000..a6a3e08 --- /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 0000000..748289c --- /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 0000000..d5db0c7 --- /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 0000000..2348b97 --- /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 0000000..ab23a4c --- /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 0000000..8060baf --- /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 0000000..482e437 --- /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 0000000..ad929c8 --- /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 0000000..9668838 --- /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 0000000..c73331b --- /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 0000000..35be576 --- /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 0000000..2f96dd7 --- /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 0000000..13e9dbc --- /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 0000000..45e5034 --- /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 0000000..9eb3a11 --- /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 0000000..3d5b717 --- /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 0000000..58d0ee6 --- /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 0000000..af2885c --- /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 0000000..18742ed --- /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 0000000..24bf9a9 --- /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 0000000..6906167 --- /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 0000000..87c405c --- /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 0000000..bc7083d --- /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 0000000..2d8886e --- /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 0000000..299abc6 --- /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 0000000..d4ce336 --- /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 0000000..0b8be7b --- /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 0000000..b094fed --- /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 0000000..87e50b3 --- /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 0000000..701d69f --- /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 0000000..af50442 --- /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 0000000..3a5112f --- /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 0000000..d87b7f2 --- /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/85] 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 e94ce11..6db446c 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/85] 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 0000000..68dc626 --- /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 0000000..4980802 --- /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 0000000..2e89fb3 --- /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 0000000..5ad1e3e --- /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 0000000..c41941f --- /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 0000000..1dc794f --- /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 0000000..9108a75 --- /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 0000000..e1ff519 --- /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 0000000..b9a6e27 --- /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 0000000..35ce70f --- /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 0000000..6846796 --- /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 0000000..fc401da --- /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 0000000..bddd6bd --- /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 0000000..9692451 --- /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 0000000..3722103 --- /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 0000000..b7db335 --- /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 0000000..7e05824 --- /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 0000000..55f11f0 --- /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 0000000..bea0070 --- /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 0000000..1a4ae25 --- /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 0000000..c2f47a7 --- /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 0000000..02a71bb --- /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 0000000..afdcf9c --- /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 0000000..10b1b49 --- /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 0000000..155e2ee --- /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 0000000..4609a1e --- /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 0000000..cb84ef1 --- /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 0000000..9ad73c9 --- /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 0000000..a9404d0 --- /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 0000000..bf38c77 --- /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 0000000..78ca424 --- /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 0000000..6fc7e6c --- /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 0000000..09a7e3b --- /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 0000000..f9810f7 --- /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 0000000..df47c93 --- /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 0000000..70da0de --- /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 0000000..da19e17 --- /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 0000000..c8ad230 --- /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 0000000..d861d65 --- /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 0000000..027c6df --- /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 0000000..528bab3 --- /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 0000000..6f5f188 --- /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 0000000..e3e6a3c --- /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 0000000..1001120 --- /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 0000000..ab8cd5a --- /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 0000000..9f041cd --- /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 0000000..38079bc --- /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 0000000..a73038b --- /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 0000000..49918f0 --- /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 0000000..8efa79a --- /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 0000000..82a94c2 --- /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 0000000..16664dc --- /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 0000000..441c461 --- /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 0000000..c44e1f2 --- /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 0000000..8158de8 --- /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 0000000..fb10fc0 --- /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 0000000..2ba52ff --- /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 0000000..73c6557 --- /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 0000000..8828dcf --- /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 0000000..bda29a4 --- /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 0000000..b186ac1 --- /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 0000000..344ed78 --- /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 0000000..8d95e5a --- /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 0000000..d2f3b15 --- /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 0000000..209cbde --- /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 0000000..7b9ae10 --- /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 0000000..97e73c5 --- /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 0000000..4bb01e3 --- /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 0000000..962466f --- /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 0000000..db15edc --- /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 0000000..582ff66 --- /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 0000000..3210881 --- /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 0000000..94949b3 --- /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 0000000..73dd846 --- /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 0000000..69de96e --- /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 0000000..20458ca --- /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 0000000..c3f9886 --- /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 0000000..a738bc8 --- /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 0000000..d7de8b9 --- /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 0000000..8c8cf9b --- /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 0000000..650c0de --- /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 0000000..43a6908 --- /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 0000000..d83fecf --- /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 0000000..d9f3569 --- /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 0000000..9d63945 --- /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 0000000..8ce8757 --- /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 0000000..037108b --- /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 0000000..ebbc30a --- /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 0000000..5860757 --- /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 0000000..0d33652 --- /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 0000000..512307f --- /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 0000000..3c2a3d0 --- /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 0000000..c749034 --- /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 0000000..e8b0896 --- /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 0000000..34d52a8 --- /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 0000000..0575317 --- /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 0000000..9b419da --- /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 0000000..a2872e5 --- /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 0000000..cc4437c --- /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 0000000..64d78d5 --- /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 0000000..fa28fa5 --- /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 0000000..e4b8c26 --- /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 0000000..0e99f00 --- /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 0000000..22a7744 --- /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 0000000..2c6198e --- /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 0000000..f561273 --- /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 0000000..7ce377d --- /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 0000000..0d4739d --- /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 0000000..3d91289 --- /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 0000000..9b0532e --- /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 0000000..fb3dc17 --- /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 0000000..7b040b0 --- /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 0000000..6a36c5f --- /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 0000000..39f682d --- /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 0000000..100d823 --- /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 0000000..eae79ba --- /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 0000000..3fe6f98 --- /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 0000000..e73df7c --- /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 0000000..42a50a2 --- /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 0000000..27049df --- /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 0000000..fda1bdb --- /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 0000000..ab18d64 --- /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 0000000..3ac9e7c --- /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 0000000..8c1898b --- /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 0000000..783e001 --- /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 0000000..2ebc60f --- /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 0000000..dbb5001 --- /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 0000000..c9bdc36 --- /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 0000000..2474902 --- /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 0000000..26a1bb6 --- /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 0000000..bd97eb9 --- /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 0000000..2d60bdf --- /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 0000000..d8b3b9f --- /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 0000000..62668bd --- /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 0000000..6c3729b --- /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 0000000..2051478 --- /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 0000000..36b6531 --- /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 0000000..0d552e5 --- /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 0000000..202f17b --- /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 0000000..1f45979 --- /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 0000000..26c85d5 --- /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 0000000..15f4496 --- /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 0000000..bbf5c4b --- /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 0000000..4ebf32d --- /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 0000000..4f478bb --- /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 0000000..e4bde7f --- /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 0000000..b709714 --- /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 0000000..7f7d698 --- /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 0000000..67867be --- /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 0000000..21caf77 --- /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 0000000..33bf472 --- /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 0000000..2eb3991 --- /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 0000000..997beab --- /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 0000000..bdeecc0 --- /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 0000000..48146f9 --- /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 0000000..10de04d --- /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 0000000..2babd5c --- /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 0000000..87364b9 --- /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 0000000..4328211 --- /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 0000000..a9011bd --- /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 0000000..7f9b93b --- /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 0000000..5c313fc --- /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 0000000..751ddcb --- /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 0000000..a5b90a5 --- /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 0000000..9a07dca --- /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 0000000..4c5fc2e --- /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 0000000..f6797ac --- /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 0000000..114688e --- /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 0000000..7224596 --- /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 0000000..581cba4 --- /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 0000000..7e01875 --- /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/85] 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 8158de8..dfee81f 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 209cbde..7b2288f 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 69de96e..b570e51 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 0d33652..bd29975 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 22a7744..deb286c 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 100d823..0f44a46 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 2ebc60f..fbde6bf 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 202f17b..0850f6e 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 21caf77..dcb4f2b 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 7f9b93b..58f030e 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 7e01875..db513bc 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 0000000..f08cd5e --- /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 0000000..71778bb --- /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 0000000..daae059 --- /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 0000000..efa092c --- /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 0000000..bffbb9e --- /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 0000000..f13db4a --- /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 0000000..fd89d61 --- /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 0000000..bc82180 --- /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 0000000..b3f9f9e --- /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 0000000..355c8f2 --- /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 0000000..3039823 --- /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 0000000..5b44a0d --- /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 0000000..4495d2b --- /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 0000000..86941c1 --- /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 0000000..c806d93 --- /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 0000000..9e06712 --- /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 0000000..1c76772 --- /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 0000000..2e1a313 --- /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 0000000..2bee729 --- /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 0000000..50a95db --- /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 0000000..96ba1e1 --- /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 0000000..8b5dbfe --- /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 0000000..1814ffd --- /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 0000000..d87d840 --- /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 0000000..3c83615 --- /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 0000000..5408547 --- /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 0000000..f010fe2 --- /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 0000000..7ea874e --- /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 0000000..a007908 --- /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 0000000..e11aa8e --- /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 0000000..dc0e270 --- /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 0000000..08c535c --- /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 0000000..2719d22 --- /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 0000000..7c5e1de --- /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 0000000..5d5e4ce --- /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 0000000..fd07635 --- /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 0000000..0d794ad --- /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 0000000..57eff4d --- /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 0000000..5f64a91 --- /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 0000000..aeaa384 --- /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 0000000..dd10b7d --- /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 0000000..b6a87f4 --- /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 0000000..3d2218e --- /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 0000000..a9e16f9 --- /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 0000000..45d1886 --- /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 0000000..1a78dd4 --- /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 0000000..0858673 --- /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 0000000..05bb398 --- /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 0000000..87e3ec6 --- /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 0000000..ee4082c --- /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 0000000..c4f8cf8 --- /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 0000000..384d652 --- /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 0000000..913c69d --- /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 0000000..4cc4310 --- /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 0000000..4de0afc --- /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 0000000..8501eb0 --- /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 0000000..c6193dc --- /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 0000000..672e881 --- /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 0000000..97fdceb --- /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 0000000..727efb2 --- /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 0000000..895e8cf --- /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 0000000..bc8602a --- /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 0000000..a200e68 --- /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 0000000..e429e6c --- /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 0000000..aa5f703 --- /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 0000000..85819bf --- /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 0000000..0b09927 --- /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 0000000..4bdf2f5 --- /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 0000000..851b4bf --- /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 0000000..2cc0940 --- /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 0000000..411530e --- /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 0000000..6503462 --- /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 0000000..acd462a --- /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 0000000..179b361 --- /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 0000000..fd00ded --- /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 0000000..cba49f0 --- /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 0000000..94cbd19 --- /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 0000000..5cd6365 --- /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 0000000..6a4c276 --- /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 0000000..24518f4 --- /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 0000000..5ffc800 --- /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 0000000..396fa85 --- /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 0000000..fdae211 --- /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 0000000..9cacb49 --- /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 0000000..3efdb8e --- /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 0000000..a996ced --- /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 0000000..f301a6a --- /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 0000000..1821fe3 --- /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 0000000..6c2d694 --- /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 0000000..247bb6f --- /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 0000000..017602a --- /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 0000000..43e12d5 --- /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 0000000..ab27cc7 --- /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 0000000..f6e0783 --- /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 0000000..459eb5b --- /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 0000000..4b22990 --- /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 0000000..293c831 --- /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 0000000..9ee5fbc --- /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 0000000..789a1dd --- /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 0000000..9da2fd7 --- /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 0000000..fb83976 --- /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 0000000..2f627ff --- /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 0000000..df5704b --- /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 0000000..6278f67 --- /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 0000000..bb37e12 --- /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 0000000..dc5668b --- /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 0000000..531bfa3 --- /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 0000000..6bae5c7 --- /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 0000000..2129bf8 --- /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 0000000..0d7815b --- /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 0000000..f750340 --- /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 0000000..708e89d --- /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 0000000..6632bb6 --- /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 0000000..4578bea --- /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 0000000..3c5fd80 --- /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 0000000..57c0c89 --- /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 0000000..2e7724b --- /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 0000000..54a9229 --- /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 0000000..07bb354 --- /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 0000000..1534f1b --- /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 0000000..19b9030 --- /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 0000000..2c0989f --- /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 0000000..f6f06c6 --- /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 0000000..2cc150d --- /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 0000000..06bcfa4 --- /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 0000000..869213f --- /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 0000000..d2cbfc1 --- /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 0000000..32f51e5 --- /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 0000000..1ff798b --- /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 0000000..3c6c1d8 --- /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 0000000..69c5ac5 --- /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 0000000..621904c --- /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 0000000..ce4ed46 --- /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 0000000..e974585 --- /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 0000000..ae24cc2 --- /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 0000000..1c5e39d --- /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 0000000..0fa445e --- /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 0000000..fa7b446 --- /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 0000000..4ccca0f --- /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 0000000..2767432 --- /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 0000000..daa7c92 --- /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 0000000..f7b8588 --- /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 0000000..03403b1 --- /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 0000000..6f8fc42 --- /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 0000000..5a1576f --- /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 0000000..08282ff --- /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 0000000..43ce1da --- /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 0000000..dde3231 --- /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 0000000..940b55d --- /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 0000000..a950acb --- /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 0000000..e01b167 --- /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 0000000..ae9fcaf --- /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 0000000..5753fcf --- /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 0000000..fe6984b --- /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 0000000..9d582c8 --- /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 0000000..86154b3 --- /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 0000000..87c7d0e --- /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 0000000..c107382 --- /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 0000000..5fba9aa --- /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 0000000..d8f2c39 --- /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 0000000..6bc5aa4 --- /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 0000000..46f8bec --- /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 0000000..9e09aa7 --- /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 0000000..9e74f52 --- /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 0000000..2f31c55 --- /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 0000000..5a0820b --- /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 0000000..98f86b9 --- /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 0000000..1470a16 --- /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 0000000..d02f561 --- /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 0000000..d66e120 --- /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 0000000..9f58e14 --- /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 0000000..787a0c9 --- /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 0000000..f1478c7 --- /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 0000000..50ad841 --- /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 0000000..a9c3fe1 --- /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 0000000..78b5b18 --- /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 0000000..8f8538d --- /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 0000000..84a5aa3 --- /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 0000000..9cdae26 --- /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 0000000..8b2c421 --- /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 0000000..d608b2a --- /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 0000000..5fb249b --- /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 0000000..75415ba --- /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 0000000..0f1f25e --- /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 0000000..6917d6a --- /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 0000000..0fef31d --- /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 0000000..386b0bb --- /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 0000000..b82cf71 --- /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 0000000..0fd6e91 --- /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 0000000..5230342 --- /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 0000000..6bc43c9 --- /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 0000000..ee028f9 --- /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 0000000..4342019 --- /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 0000000..1ce0361 --- /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 0000000..7a8bdec --- /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 0000000..f0f4f5a --- /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 0000000..e4812f8 --- /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 0000000..b26d07f --- /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 0000000..85fa208 --- /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 0000000..d9016d3 --- /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 0000000..09dcf0c --- /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 0000000..987980e --- /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 0000000..fafb674 --- /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 0000000..71b0351 --- /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 0000000..fbd7d81 --- /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 0000000..1567f75 --- /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 0000000..49af585 --- /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 0000000..656e161 --- /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 0000000..491405f --- /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 0000000..b2237ee --- /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 0000000..950d3a3 --- /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 0000000..d107547 --- /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 0000000..03d6985 --- /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 0000000..e21c936 --- /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 0000000..000b817 --- /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 0000000..04e96a6 --- /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 0000000..ce6007e --- /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 0000000..c272fb6 --- /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 0000000..f817779 --- /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 0000000..7e3d339 --- /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 0000000..817c07b --- /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 0000000..2d1f894 --- /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 0000000..d3b6657 --- /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 0000000..f03fb68 --- /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 0000000..8c65df4 --- /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 0000000..5340905 --- /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 0000000..4e0b549 --- /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 0000000..b124908 --- /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 0000000..76988db --- /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 0000000..ed0b3fc --- /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 0000000..74938ee --- /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 0000000..7671303 --- /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 0000000..574bd92 --- /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 0000000..4356dd5 --- /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 0000000..7b13bc5 --- /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 0000000..c72eea0 --- /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 0000000..1de5b11 --- /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 0000000..aa51601 --- /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 0000000..e458f9f --- /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 0000000..4fe659a --- /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 0000000..85fdeee --- /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 0000000..51a2742 --- /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 0000000..74cff4c --- /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 0000000..5a6a218 --- /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 0000000..dea8c57 --- /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 0000000..e0d7d8b --- /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 0000000..b4c33d5 --- /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 0000000..d30799e --- /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 0000000..2a46129 --- /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 0000000..fd7c6ec --- /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 0000000..969408a --- /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 0000000..24bde29 --- /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 0000000..f376efd --- /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 0000000..d73d1aa --- /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 0000000..d81f171 --- /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 0000000..4c108e5 --- /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 0000000..cec1e8f --- /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 0000000..62b003b --- /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 0000000..8dfcfbf --- /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 0000000..5394b69 --- /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 0000000..42af3fd --- /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 0000000..542ffd0 --- /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 0000000..fbbf225 --- /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 0000000..bee793c --- /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 0000000..13e7229 --- /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 0000000..157aaf8 --- /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 0000000..834b7fe --- /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 0000000..98bf65f --- /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 0000000..80e5104 --- /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 0000000..4ad9881 --- /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 0000000..ffeeae1 --- /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 0000000..a5a1765 --- /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 0000000..442b8ba --- /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 0000000..2a2b8df --- /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 0000000..547f317 --- /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 0000000..d815fbd --- /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 0000000..d63fa32 --- /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 0000000..64352fd --- /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 0000000..af3ff6d --- /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 0000000..f36bae9 --- /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 0000000..fa42051 --- /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 0000000..960e91f --- /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 0000000..0b39e4f --- /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 0000000..ae9531b --- /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 0000000..c74f685 --- /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 0000000..6bce48d --- /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 0000000..6e946e4 --- /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 0000000..2e586d7 --- /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 0000000..9b29073 --- /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 0000000..ad97cdd --- /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 0000000..a5f1fe9 --- /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 0000000..4103ae9 --- /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 0000000..58bf9b4 --- /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 0000000..253b006 --- /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 0000000..60d2d38 --- /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 0000000..31e6dcd --- /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 0000000..3635fe6 --- /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 0000000..0931ce9 --- /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 0000000..39c474c --- /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 0000000..5af303f --- /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 0000000..01d2174 --- /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 0000000..cf72cc7 --- /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 0000000..a4de656 --- /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 0000000..37f81eb --- /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 0000000..3263508 --- /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 0000000..0b98246 --- /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 0000000..55b64ef --- /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 0000000..a884475 --- /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 0000000..b30ae7d --- /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 0000000..a2d9aff --- /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 0000000..92a73e8 --- /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 0000000..fa2d55e --- /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 0000000..a7f561c --- /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 0000000..cb32a26 --- /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 0000000..170190f --- /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 0000000..c30184f --- /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 0000000..a3c5634 --- /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 0000000..cccd545 --- /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 0000000..b16754b --- /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 0000000..00df851 --- /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 0000000..a34fef1 --- /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 0000000..e2c6cd3 --- /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 0000000..80de6c3 --- /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 0000000..c240914 --- /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 0000000..0e55d13 --- /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 0000000..5f75fc8 --- /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 0000000..a419b32 --- /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 0000000..6f421a4 --- /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 0000000..ebf46bf --- /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 0000000..b59b394 --- /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 0000000..665d2ea --- /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 0000000..9b48eec --- /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 0000000..b4060f2 --- /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 0000000..e0f8710 --- /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 0000000..834a85f --- /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 0000000..16ad84e --- /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 0000000..6887020 --- /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 0000000..debfbf3 --- /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 0000000..a4f194c --- /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 0000000..9179ae5 --- /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 0000000..2f10ca0 --- /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 0000000..3e46470 --- /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 0000000..6b00e53 --- /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 0000000..a8ae608 --- /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 0000000..78c6ffe --- /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 0000000..ea853ba --- /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 0000000..f3ffc4f --- /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 0000000..6ec7f44 --- /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 0000000..7fb114c --- /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 0000000..006d5b6 --- /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 0000000..a67b006 --- /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 0000000..4749467 --- /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 0000000..9f86e8b --- /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 0000000..ed00c00 --- /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 0000000..fc0ebbd --- /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 0000000..2d1a6dc --- /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 0000000..e59149a --- /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 0000000..0128c08 --- /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 0000000..38d8b5d --- /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 0000000..61a2d60 --- /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 0000000..986be99 --- /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 0000000..304c454 --- /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 0000000..a105abd --- /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 0000000..0a14a5c --- /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 0000000..dea7182 --- /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 0000000..1e737ef --- /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 0000000..a0dd25d --- /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 0000000..f5a6145 --- /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 0000000..8b6497f --- /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 0000000..56d21e4 --- /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 0000000..0dd5edd --- /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 0000000..f5f72cb --- /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 0000000..30ede9a --- /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 0000000..d43968e --- /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 0000000..eb3c3f3 --- /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 0000000..562459f --- /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 0000000..9cfcfeb --- /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 0000000..91cd4e3 --- /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 0000000..010c56f --- /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 0000000..0213351 --- /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 0000000..af9fc60 --- /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/85] 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 b26b5cd..682f928 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 b567de0..f950e90 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 198a29e..38e89d7 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 7ea7ba8..8962502 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/85] 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 128217f..eae057d 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 e4c3cd4..ba779d8 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 abe267f..1b72a7b 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 81e359c..4163a7e 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 17d0f88..fafaf3b 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 0e53c3b..db00981 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 0d72ab1..a86dc70 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 13e6333..53ea619 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/85] 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 1039266..8ac13dc 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 0be6231..ebc7f13 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 a983871..2ea9439 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 a57e9f5..f28309b 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 a47cc8c..0e8618c 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 0b90f09..6b871d0 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 18172fa..82fb455 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 3dbff08..cb3551d 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 228e9e2..3bd684b 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 18ca4af..ffd82a6 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 2ab99ed..1273d48 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 63de504..32f6e01 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 d93c3da..f6d75a4 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 f3689c7..4ed2204 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 920dbcf..79c3911 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 877b7d3..392de43 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 ddb5518..2993c9b 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 7b7247b..06f0117 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 b30769c..cebda7d 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 fb38a2d..eb87909 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 60a65ed..bbf8a1b 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 cf86cc5..48d7892 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 1eab3fc..f58b252 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 c5b0eed..85a7752 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 1ca4908..cb4b109 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 1c818ad..b7a10a7 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 242143d..9ee3b4f 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 9ce4c0f..649811c 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 d47205a..8567f4b 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 24416f3..2df0c2e 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 f7a854c..11259d8 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 7fe3a72..18dda71 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 27097f9..5803ba1 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 347c50f..f5f67a4 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 dee0547..1e19923 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 21a52a5..ae08162 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 a9efcc8..bbc4674 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 ae38019..a34f321 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 8bdfbb8..2482988 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 54a2c4d..e6e4d5e 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 299ff3e..681d168 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 d8754fb..8b9c0c3 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 4bc4ab0..a1526df 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 cb2dc14..418d20f 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 7017499..6ffbe2d 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 87a86bc..eb40083 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 87aec8c..acfe2a4 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 5ba1f7a..3374a41 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 4ea2fec..2f0d84b 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 94a39f4..955624e 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 01c9ee6..90ffd8c 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 9e7c296..ad5abd1 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 2b30e79..72963dc 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 094a1e4..394719a 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 28fa8e1..fe5fdf8 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 307d2ac..9c82910 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/85] 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 6b38bb7..9c648e4 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/85] 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 0f9d117..57300b3 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/85] 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 52908e1..22a5422 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 eae057d..9b48ac9 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 ba779d8..e341d27 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 88cfd0c..41dbb5e 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 80ae696..265f890 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 cd51571..2efa288 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 1b72a7b..80bf7bf 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 80f798f..e7deeb0 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 10c64ef..3529ea8 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 c49c8b6..885b589 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 4163a7e..805bbd8 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 797a50e..eb78ff9 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 babf9b5..87b0088 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 a2ab576..d6043b5 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 6d04b0c..be51dbc 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 7ece174..745a628 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 125a328..96a336a 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 103c662..fafd0a5 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 c540065..6636e70 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 6eb5a3f..a870540 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 ae7881b..44be46a 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 6c30105..91aa171 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 ddd13e6..1ccab5a 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 db00981..29b07f7 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 bb3ceab..3276d77 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 13e97ad..b3da19c 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 26a3c51..dbefae9 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 71b6876..bc3e8b0 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 17d679d..ecb14cf 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 e8760a7..8b3a309 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 1ebdb28..950bd36 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 87197b2..42e8fc5 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 2a600e9..1d8c937 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 a4e43e4..f098264 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 516389f..8b96d05 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 854eace..4278d15 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 c83e804..0941b94 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 6a16483..92db62b 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 31e73ea..19b1c02 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 a86dc70..896b1a3 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 97ff67d..fa2e422 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 96668ed..c73bf00 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 53ea619..149dc9f 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 36afb32..8545c16 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/85] 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 0000000..154af65 --- /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 5e3543d..fe5a78e 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 122943b..2f326dc 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/85] 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 acec196..8a45338 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 bfdf652..68290c6 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 d2f3ef6..494c4ff 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 0cb5e61..064cf7e 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 57860d7..0eaf688 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 8575f89..26834fb 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 7ba631c..7025541 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 179e987..f581fbb 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 9d525fc..5cecfc2 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 d14bcfd..02bfc06 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 6952916..bab5d92 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 1409340..3e1bc4a 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 ecb0197..856c81f 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 65fe48c..4cf4cf6 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 ae9c438..7285ff0 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 84d8fa6..1f6244c 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 d02a97e..dc94166 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 15b04a0..24209f7 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 cd4387f..05bf735 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 89389f9..9df7884 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 8dd6243..e51444f 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 222839a..1987cae 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 50c2282..5563b2b 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 183c069..127215e 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 9cb9734..c149600 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 d505674..db51937 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 fd929a8..c0debbc 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 b25cd2e..a187d41 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 3347e24..8456e5c 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 de5a3cf..984843b 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 b456bc4..3d145c5 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 881f666..89074c4 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 c15512c..d3a3545 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 349b264..644bb57 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 18ceed9..09e4d40 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 a07325c..e8c1b09 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 ea29a5b..460ccd2 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 4aea08e..1d66bec 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 136873f..7d4ff1d 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 e7b5c04..c427c01 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 c8cd033..d7aebc1 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 8e7b5a9..d38ee95 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 22264e9..ba3b3ce 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 e082440..2304943 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 d15cce8..b92221a 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 f731b94..35897e3 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 1bd5b6c..8a3ab63 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 64ac38e..9fa216b 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 4adb1ff..b45c476 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 5d33208..4475d72 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 3c79a94..3268ed2 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 314b0e1..47f1687 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 7ecc1c7..95f0eee 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 ad61ba9..758007e 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 a0ed744..6541a8b 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 ff6ebf8..c8dcd19 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 1dec12f..244b664 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 7074f46..1607d78 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 2ae208a..e89ed79 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 f2f2e55..39e21e5 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 1dab40c..41c72c1 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 dff0d9c..573a776 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 62885ee..a6548fb 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 938b4ed..3cee96f 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 b13912b..d111aa0 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 8c38fd2..3f20227 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 926c58a..25602ce 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 42a1cff..6e747f2 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 c536b8c..099e481 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 378633a..a84ae4b 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 688b4fa..692d85c 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 95bc094..d2f7ce0 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 9c15922..abb2a94 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 180da3b..eab2ed2 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 45e3774..bde9b35 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 445e4b5..ff533f2 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 3b3408a..f04a7e7 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 f647532..b957e4f 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 bb4e5c2..dfe53f1 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 a90d867..9b4259f 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 d91b35e..518382e 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 f61ed59..f6c97ad 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 656ea71..5291625 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 b2798f3..556fbeb 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 e556ccc..ad0350d 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 7a6d9a7..1675e13 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 ce028c5..0ee4709 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 8387ba6..6147fc0 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 68da325..cb5e69a 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 315d955..f734c27 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 ae98819..b8da3e8 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 c47ee41..1f3a66a 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 15eeeb3..7d95991 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 a36f5d6..682b84e 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 37d0717..ccb02dc 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 ca38f83..cfcdc34 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 a8871cf..4f5eb19 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 690bd8d..87d4a7d 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 a730aae..c7b64fa 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 d0ddcba..078f21b 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 77c4093..b408e4e 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 1535207..1ecbe71 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 456d7e6..8569636 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 2006c5b..2152cf5 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 48e97de..036c61b 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 955e4d4..cc90480 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 a07df24..936224e 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 43aa1e4..9d3e902 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 c05dfea..604f2a8 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 730c1f4..c9d6864 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 4e23e04..3310bc7 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 1a9fe6d..3ab6588 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 669461e..5304064 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 8ddad88..83a731d 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 b65cfef..07404ea 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 9bdf6ba..ce3b7eb 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 ad8172e..3e8190a 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 3286d9b..9a82536 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 99c53e8..fd7d128 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 cabb8f7..e456e13 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 eab5da7..8911626 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 a68ba99..3dcbd52 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 c418250..154cb1c 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 52eba02..8c9b8d6 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 54f1a95..98efe9f 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 0978e77..224fc45 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 b40b212..b83926e 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 a0a3ec3..b571c55 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 52cebd7..e801c36 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 f7809af..b3b503b 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 0ef0eab..1f1e022 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 1878d42..d53b87b 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 2fc5648..f62170e 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 3eb6676..7a4d5cb 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 2156444..728b36e 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 49f6763..f0e12d1 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 95fea23..7213007 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 91713cb..9df0bb2 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 513b5f1..14dfa0c 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 409f7db..add856e 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 703c967..c40e7d6 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 c7da59a..78ec751 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 c075961..8218bf5 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 4fab045..900a648 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 4e3502c..45e26c1 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 fe14736..2eb9636 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 a4863b8..51eb42c 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 852683c..2e1155b 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 3623a07..929f48b 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 f8cdb9f..733e8f6 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 2d9c3b3..e335427 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 0fea952..8edfcf5 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 ad529d7..36a1514 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 1d28903..9572080 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 2f3982a..4d81422 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 2212e8a..f06c094 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 4efde12..22e047f 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 7ddc9bb..790e2db 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 bf1f5ce..ae608a9 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 e926f2a..fb988be 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 9db68a2..dcb725e 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 d7e2750..54b5c0f 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 122f4b0..ff99065 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 e1aafcc..318b760 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 673c1be..cf80716 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 bbff3e1..8ef40d0 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 2089d2e..1ad8c11 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 be13bf1..d88a75d 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 7bc2970..33d0063 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 097e35c..05966a9 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 c960850..2f45406 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 43afa62..f0ecefd 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 d6dd987..f8c6d60 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 b06ff32..3c49138 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 3b3e241..1e75a59 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 329a42f..329bd6c 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 af17fd5..a4b63d5 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 b46ba69..16bc2a5 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 cd46f77..131d48f 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 554dd40..5d4fa5f 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 72c207a..777e60a 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 c3222fb..4c70e39 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 ec09a78..fd5f49b 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 d7cb369..2fa534a 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 7be32b1..873f01f 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 9a6a772..a84696c 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 e7570e2..4b791cc 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 79828f5..241be65 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 f848709..44659bc 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 e2224e8..a4faf39 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 2326db0..118ee68 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 1cdda61..ddd10e9 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 ac98b50..f97f277 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 3ed9a62..4428c75 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 0768814..1a05a42 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 bc2f78e..f399c71 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 bf9f91b..f8d1db9 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 ae90606..8fdb5ba 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 6eae8ea..74bb08f 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 9741a9e..c53ae98 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 db91fb7..2802123 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 e2f736e..d8cbdf3 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 50b2532..3f9222c 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 7ab2565..1b49e0b 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 e41c7c3..489dfd7 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 6ce6d63..d9bd7a4 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 1f525e9..7e91442 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 fa4c880..c9d0d96 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 44d0642..2a1c162 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 81258ce..f78eee3 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 53db492..c310248 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 bf5a05e..cd22bc5 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 f8913da..517c7ee 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 280480c..525f865 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 fb398b9..6ab172c 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 ba14d2c..b474bfe 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 d979a18..45571f9 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 f8ce0c5..ee52d33 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 0c923be..cf16d62 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 a7c4a2c..470b354 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 b8881c7..2683593 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 0feded8..c6a5e9e 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 951ae3a..ab86d1f 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 32580e4..9564074 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 dae1f2f..4146547 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 90b6c7b..eeb1f32 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 b0bcacd..3b6cbe5 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 c18c954..9cc1acc 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 b6bd43d..9be3a35 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 8f39352..73e2a0a 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 70422b0..f90d28e 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 6c16baa..ec96f5d 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 298f8ec..35a92bb 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 bdabd9f..b8e3aca 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 6898af2..88ed702 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 584d12b..7ec03a6 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 b6894c0..5079ffa 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 afe2231..c7bddbe 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 d7d2faf..ca92e32 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 dbffa5d..81099b2 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 abc268d..cceca86 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 01d3dda..3088b5f 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 3c48f79..670f1a1 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 53898d7..e6a89e1 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 eaac7fe..5f11447 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 77a045f..d57f276 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 f797dcd..b096aa9 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 866da14..c3988d4 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 3a2e28a..6690a27 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 8cb9e20..a046d86 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 8acdd2a..1aa11bd 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 ba9ac25..3f1aaff 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 943f082..261752b 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 dc924b4..b4d3d24 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 d38d26f..9ac34d4 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 5f785cb..4ba4a33 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 f83d77d..446683b 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 e7411b6..2a3ea2f 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 180e57e..1057559 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 6cf6091..6d9ce26 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 d74106a..1e6ffbd 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 74a7f93..38eba87 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 af57484..816ebfe 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 13cb475..32c3bbf 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 4b55f40..4a90ab7 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 dfb3061..6cf0a97 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 f4e24de..588a972 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 e90400a..a854027 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 0b7925c..18729d9 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 48ac0e5..a448fd7 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 1422fab..225144c 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 8bde234..3cb68fe 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 46ee513..5a31a93 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 1a51cfe..7243899 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 336be04..ba961f0 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 d2c9fb3..939c0af 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 7bbce3b..996b92d 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 37042b1..62e188a 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 a568d7c..e90bdf4 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 2e7e989..47db6ca 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 1c5b679..9f09b79 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 4276a25..03f7bf1 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 f784f66..8259b57 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 42ae946..c7ab952 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 79850e6..ae88f3e 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 0751007..e405330 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 1cb9548..886f546 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 a8be0a4..5ebba87 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 d1274b6..dd7cb5e 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 969014e..1995e75 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 90b0ccb..a573f35 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 e6284d0..3b80b0d 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 485cf4e..47ec28d 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 6cbd1bf..46d77ea 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 cc9c7a2..ea418ae 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 d1394d6..30617e6 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 ae2baaf..41eb4bb 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 b830c25..5f7b2c0 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 74ff46c..dbe0477 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 8a1b88d..b5785c4 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 7ef9f96..e7af0ab 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 9d3ab0a..5e7181d 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 eca7cca..09d714f 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 fef2b79..f5f1195 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 d24bfdc..197681c 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 fe036db..19d76e6 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 6cae906..5643ced 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 6eaff86..9d9273a 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 b483310..57831ea 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 1186825..d2aa049 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 39b1924..dca0314 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 0025e34..c77e221 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 2761cda..5ed8a79 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 8fb7bd5..e72787c 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 f7c5cfc..2d23877 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 80eb992..fd2dcaf 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 a4567c3..92d54a9 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 e871d26..636f90a 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 a045abc..60a6022 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 04fdb37..278a36d 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 1003e2e..2d5195e 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 73794c5..5138235 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 56d86fe..263c1f2 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 938ce7c..51644ff 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 48af075..d724c8b 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 737cf37..f9155d7 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 5370be3..bfdd0c9 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 d77f43e..1142e1d 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 b8cc788..e4be72f 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 c5c228d..33fd1db 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 5f78d9a..f77348b 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 4f1097d..4f21698 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 34c08f9..93ff35e 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 fdf5bbd..dcedeea 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 2dd5353..23aca02 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 ee9d5fc..a0b98e1 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 f372076..779d1db 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 43f4049..0d9f579 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 9985a93..575c259 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 2abf87f..b6d4c91 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 be8d61f..a18761d 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 702813e..82c0b88 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 2190aa8..f544336 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 f815237..e43d209 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 92c5698..ff48b48 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 7b667e5..e727bda 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 81a4532..72864f1 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 f3da36c..4918e9f 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 c1fb889..2d4f8d8 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 34bb880..b4fdd74 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 8bc4169..8e56b57 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 8f2a5d2..1fa063b 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 e1be141..39c796d 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 54ef23b..d7b313a 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 19d6186..2b40cb2 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 14eaeaf..69b8fc6 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 f6b8142..6959e33 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 af0247a..09fb022 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 601d1b9..049726f 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 14c6556..7c05e3a 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 8a15b00..ba1ede7 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 cdc7f90..f5241dd 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 a1a2ebd..3919447 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 003edd4..bbff097 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 f1a9b09..0c52a7f 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 476394b..109ec78 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 e09a0f3..b46ff08 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 6432aad..fc50f18 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 0e93c17..bbd4539 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 3b32ed2..e7850c3 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 9971111..5212d39 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 1515b7d..515c22c 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 b900047..77050bb 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 d9756dc..bbfb996 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 b71ea7b..266c1eb 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 10fe362..8be518f 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 387487a..ad630ab 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 5369205..d5247fa 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 115bd4b..3fa29ac 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 2215f5b..9253902 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 450d5fc..35d5e2e 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 3f3cf08..2fd697b 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 ad884ab..92f80b4 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 75f90c0..2d1c99b 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 2e1bdc9..a295858 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 49fd3d8..e9f54a3 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 c04f2a3..bed0dfd 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 fc5e8ea..4571abf 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 b89431e..140bcff 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 4526d10..77c7d13 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 2a40fa4..477eae8 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 ae91f34..bd4af01 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 283f887..210736c 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 92d3442..049eda5 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 0da3e4c..4bc4e7b 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 91891e4..e325fc1 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 148996e..9671739 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 16f214b..667f0f4 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 4c9fb59..e6255fa 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 5ad9501..a51df5c 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 a373eab..394f2eb 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 a3a5006..a224be2 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 61b88f4..fa5232e 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 ab25d7f..459c69a 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 89828a1..95eadb5 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 26bf20c..94f6731 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 8397fda..b8209c0 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 fcd3557..b31520e 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 1b8b4a3..2a5aec3 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 d917ae0..e1ef6b7 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 adee1fd..895b8ad 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 e9ebc9b..dc63c92 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 39e03a8..7ed10b3 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 4ca6047..f919361 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 325ea7b..0dceba5 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 520a888..e64582f 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 8e0e142..169d7c9 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 1b48fa8..19108ce 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 d4c373b..23d43f3 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 3bd227f..c176839 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 652243e..16f0fbd 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 4016c43..4a19352 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 eec98e0..95e3029 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 2a39574..1663290 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 b886ba1..1046b22 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 d28e206..ae736b1 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 e349f99..f597a58 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 26d7283..6dc1c72 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 0371d9b..ca37ffc 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 e1dfa6d..8b3255c 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 2991a6a..7609a73 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 9b4387a..01744d0 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 52716ca..739bd6c 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 9abf1eb..bcc29d1 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 9463d90..dc22ec6 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 ed0ccf1..be2b024 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 e07b6fc..85d0b04 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 18a555a..46f2d75 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 21acf79..c8f4628 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 62438fe..e564016 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 98546f8..0748c0d 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 b941407..5e78e05 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 36b347e..83ca8b0 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 166640c..b811c08 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 7f71858..143fe04 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 871dd8b..c61acae 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 b1041d2..11b500e 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 ae40572..3d7039b 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 acf9871..2fea060 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 02afc08..9dd3afd 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 4d31776..29b75b0 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 660aef8..5aee4d8 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 d8a3f40..112c6af 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 7045ab8..563e400 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 1d36b2c..0a499aa 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 5852412..95b39f2 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 4b523f0..89d0533 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 0d0ee63..5ace721 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 b128222..a5e06dc 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 ee4b451..2ed4dba 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 8031c36..40c52ae 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 714cff6..9b4aee2 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 facb195..a651ad7 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 4156caa..aea6c26 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 98c9cfc..016042a 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 47ea999..31bf3c1 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 95deab0..5f9ca8f 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 22b4aab..d20b9c0 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 7dd9b4a..47099d9 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 7c33ef5..61849f8 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 714f891..53386c3 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 1af717d..8eb571a 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 7bb22cb..9436c20 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 9b2fbe7..0dcaf80 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 d1c339e..85c6cbf 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 8941075..44cba37 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 e9a6531..8c5ac0f 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 c221ba8..d0c0e7e 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 49d086f..d0da518 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 0177b20..5c4dcdc 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 bc6eecd..9f24d6e 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 b76c7af..cb37026 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 e81d4d0..8d4fe80 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 1c24e14..e9d955d 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 b41f6a8..c3a7a05 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 3d36f1e..e04fcc7 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 b89ac9a..a7d7bb5 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 069e857..f459e2c 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 9e7446a..99a6e91 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 70fe4e1..5f83547 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 466a642..9cfd8c9 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 5a9a1e2..032613f 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 82aae24..853f632 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 430a5dc..6073927 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 df39054..324308f 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 20a6d99..5ecbfcb 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 3b0f164..8a21bcc 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 5a4afbb..1b30dd1 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 196ecd8..fa19189 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 07d875a..5746c84 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 d41afb6..80670df 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 b678201..8fa34cf 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 586e4f8..9c50eb8 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 3c08875..de4b3e4 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 6743c13..83031d8 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 fc858df..51057e5 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 13aefd9..9fe1430 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 30a8fb4..b24b31e 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 0d52453..332a186 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 b7bede5..8002b4a 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 b047c9c..6c86a10 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 b14c6e9..376ac43 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 d5b2a13..499f842 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 efb23c5..9d20a7c 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 738954f..743ef93 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 40427b7..3076bd5 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 2314e94..ef5744a 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 200528e..98b9478 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 edaeb90..312945c 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 ada9f40..6ca4664 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 c36f5d1..ce94b7f 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 93f80de..7196707 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 11b1233..099b821 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 ac4c5dc..f47896b 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 a6bb34c..67a450a 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 62325e7..72ccd36 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 9234fd8..939b25c 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 d86ebcc..02b96d7 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 bcfd585..3c7fd69 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 3bfa709..698e298 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 59ae6f5..dc6cfb2 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 504a151..db0cb5c 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 32f1602..488c785 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 586a6a5..02d4e03 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 f7d9f30..e5599b6 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 4aca030..4c19585 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 7357bba..fe577f2 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 41f6aae..6804f81 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 51f0558..d2c8766 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 71044af..fb8cb4f 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 df21824..b276379 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 452567c..e1a04ea 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 614001d..ec6d34c 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 aa8df89..48d390b 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 2b5a6c5..68a9136 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 aed0b90..4daacf0 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 2958993..ab4abd4 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 31a02e9..84a4c4f 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 4860d0f..cdf762b 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 34f4442..c8f5bf9 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 8672c15..f662546 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 61dab38..dfdd3bd 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 f0c6b28..cf15636 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 b34716a..d25c832 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 7074c43..d437405 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 60b0c37..2cf546c 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 0807f5d..418bdeb 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 34d2946..573e25c 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 939d126..75576a1 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 a946b15..b30e790 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 3a2cf55..cbfdf8b 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 c69e2a5..5e928f5 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 33929a0..c534eaa 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 476870f..4ff1376 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 76f8c2f..fcb48ba 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 65d35f2..5ec5191 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 a93b875..b018e37 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 5853aa0..02fc6d3 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 626255e..57f11a1 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 e2053ca..cf06ec9 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 ed9465c..61137c2 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 476b5fe..181786d 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 18dbf1b..e17953f 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 0fe1eae..6c8e351 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 b02265d..b93975f 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 e351615..0917087 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 52b3eeb..38220a8 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 6a8a8ec..cfc6a99 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 211e8f3..59b860c 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 a1b4e6a..563bdb5 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 23c66eb..8d56547 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 28aef8b..aa617ef 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 deb0956..c38eb4a 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 20e71ee..5a2efbd 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 7293efd..29f04bc 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 49950eb..1af0101 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 6da3af1..eab4787 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 3d73e5c..12210bf 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 069027d..bf144b5 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 c211266..c3234ff 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 a530b5e..98883f7 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 aba47a6..05be276 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 325392d..d88b3b8 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 6ab3e47..59ba277 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 3898560..95dbeed 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 973a288..70c4ded 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 6a4fe60..0f3d258 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 54e51db..df9f4d1 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 e234659..514c2ae 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 00d63c3..92e16e1 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 7620237..fb18716 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 a36b693..6d60673 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 c4346cf..de02094 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 45f701f..41cc0bd 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 4bb2132..480e4ab 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 ad73387..7e55d86 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 3493492..1a38335 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 9527215..7da3899 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 27daec8..bec1dc6 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 499ecee..508598f 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 8e28d9a..696b238 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 cd9273c..8b942a1 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 5144053..b67a665 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 5195a55..065c3d6 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 1ec2fc0..7f2630c 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 556e0b8..7a0029a 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 b71f810..82b188d 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 c54d72c..7346c56 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 aae739f..de1c84f 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 fc0e6c7..f718938 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 53d449f..a4c4467 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 db416bb..9a8bba4 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 20376af..870fb7b 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 607762d..90b79f2 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 c83e7d3..f324949 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 aa82eae..6663765 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 2579007..2273971 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 bbef472..62ce320 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 f0668c3..34cf145 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 ab7a09b..1016e46 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 1d470be..d5ebf57 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 c061646..89e0003 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 0ee1ab9..3086326 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 25f52ae..0c40fd7 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 1d62a03..399e980 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 d26048e..65c085f 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 b7a2074..6565d47 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 d96a865..9650e64 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 68c2c4e..bda5cbe 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 1bc789b..40f2a74 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 88385fc..f971299 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 32b1a53..37b7d63 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 df0b01a..9a33854 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 2d9cad4..4d4c1b8 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 b6745b5..76ef76b 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 c54750c..08de1fc 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 fa97885..22cb0ce 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 0dfb499..497e9c3 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 6af2c9c..ca6047b 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 3247928..33def46 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 fb0aa97..92c5380 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 4160c21..e69a653 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 a58eaa5..80ab0a5 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 e6b31d1..d7beadc 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 f29f173..6c32151 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 e18b11b..77fdf51 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 800e450..718fcd9 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 ffb0ae5..6841c34 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 757981b..1ede199 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 9426fc4..725a489 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 2c4ed54..32aa979 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 9f81509..06fd9a8 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 f98b6a2..bc3156c 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 74b6b71..4fbbdf3 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 c43ae8e..fab5a2d 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 4aa4bb8..c242223 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 ea1778b..449368a 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 75bdc38..95219e6 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 a6ae743..86166a3 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 65a721d..7e2b17b 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 3b496fb..1bf6315 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 e8ab0dd..b07ae6a 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 8ce56e1..e913a3c 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 eec7784..91ea2e6 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 a3c6a4c..fe8f2b1 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 72e0146..cdbd950 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 9331d1e..8af5208 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 e5c984e..bb11336 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 4171119..4849630 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 9470791..35e5029 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 7cc1f95..bf28afa 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 e0621d9..510b705 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 f0881d4..b3d2b3a 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 741c7ad..a0b5d64 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 66e4b10..99fc018 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 153a5dd..2b3b71e 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 46728b6..0bc2e92 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 aaf4f16..83bee28 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 453d4a8..7f01f6b 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 8d421b3..a043c08 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 9f78d65..c22835d 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 aeb7589..7e8fee5 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 e1ce185..acc41eb 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 29a3b28..dfbf139 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 5e9c030..48f8847 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 04e0859..aa4620e 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 c2fe61c..1a5f844 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 fb082cf..2cadfd1 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 010a83a..1c4b127 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 3fbbee9..4316723 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 6e640c7..4a4b030 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 48747bf..8ab8fef 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 be36553..87ccec1 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 6d9053d..f4d47fd 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 0e5c5ac..96c9052 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 823ba6a..38c8eaf 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 869b7cb..3f5c8fa 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 f908e9d..fa5457d 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 535b135..4d42d01 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 e17c900..908168e 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 25ebd4c..03d00bc 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 5b8c9eb..7125542 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 4426d98..24a596e 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 89ac227..95a750f 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 872ebdb..cd9cc90 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 7dd233b..d838d02 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 e49ce69..e8e4d89 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 7138e18..5df32d2 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 3cb238a..cf0dab9 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 b514e2d..beb38df 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 6f10ef8..bd8eb3b 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 9ec2127..3905c3d 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 07f064b..34b1064 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 1a82eba..93c4b91 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 7f68cf4..a9b570a 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 8d28793..bf4471e 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 1ca3a1d..4f6ae91 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 d1853d9..f318257 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 33579b6..75efbfe 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 2fd026f..835ed6b 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 55a5b50..036310e 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 b9b78e4..30e6638 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 901cf14..a10f59c 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 ea63f85..490ab27 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 08f8dfd..2112e55 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 5df298e..b047925 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 19c714d..a2b1d4c 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 309eb89..6b07e79 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 77e7dcf..2386fea 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 8369837..5a5a5af 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 31fb6df..1b3c419 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 88a5b22..bb7b79b 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 cbecde9..1d7ac5b 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 a9c2958..5076e67 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 3bc7d9b..fa5bb6b 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 818d47f..bb932e7 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 f942afb..eb863c4 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 5eb260a..f1e24f2 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 d9ae35f..4b15d9b 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 064dcc6..6aa9c37 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 a5592df..1a1552f 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 d15967b..86088ab 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 f3eae4d..0cebe3a 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 83e2c70..f95e60e 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 2677729..a4e8c3c 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 e1dc4c7..8ffa375 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 d992d81..e353a7f 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 2bc93f0..debdcee 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 7976078..ed94192 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 7bf454f..9daee24 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 77eafe7..9864acc 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 b0d13a7..20503eb 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 61296bb..e7549b2 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 fd91a2b..2afe20e 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 e7eb428..4207b72 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 f0f9024..ff306e9 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 0a6a26b..9c0ab4c 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 823555c..332a243 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 e78fa46..117c817 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 cc926c1..85a0011 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 cc7d71d..3ba5caf 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 744cca8..e874a21 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 846687c..b6e2b1e 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 089f46c..6162329 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 8133063..f250c30 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 f7d88e1..f0d60cc 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 7dc96ed..f2257da 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 0c44795..166c045 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 1ce8be2..ab7041f 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 9dff1fd..b6539e5 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 592be3b..e8a0070 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 f240329..e145426 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 bf8302d..45cbccc 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 a88e096..197d4e6 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 59e3e9c..480a4f6 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 643ca8e..a345604 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 454dbef..c47a320 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 713c531..503adda 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 ef4b9e9..a5e8e33 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 d80f471..d6f880d 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 0bf5a46..6d4d329 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 c780901..7c1a583 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 dd25753..258fe5a 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 231544f..2ff1609 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 295c133..45cd975 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 f3c8632..70d2404 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 dda9fce..c5d4d2c 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 c787878..d7ea127 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 58347c0..19cd0cf 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 40de76e..aeb5822 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 0d6c03f..e244e38 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 1db2ba2..d7b2e90 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 b69590e..dfd4a40 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 0d61ab8..6f2a842 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 4817e5e..4f0e78c 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 dcdfaa7..b17be97 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 1abeb83..b7a2b10 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 a02bde0..33eb880 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 5167a06..062e84d 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 662224d..a036888 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 4fe47ea..1761c10 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 5539560..1ff1636 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 f0e9b58..8d68a99 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 9d251ba..07c4750 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 9030981..3067955 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 fb7a699..22dd26e 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 697d323..58eedc2 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 0d09091..64c0571 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 1fbd877..c3740a3 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 2d7439c..dba7549 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 c2946f9..3c28b54 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 3d8da3b..6320559 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/85] 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 0000000..9e7a99b --- /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 43fb231..763f61f 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 bce2724..31e9597 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 2f0431c..2a27740 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 fc27a80..d6d2fb6 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 8ee106f..45e4da1 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 3170142..7c972c1 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 46675c8..d5f2be6 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 384265f..3f3ae7c 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 3ffea3b..c27c5fa 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 fbfc42e..d3b5d96 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 32f72ac..e01f018 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 c158186..6ebcd95 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 2e02952..b30773f 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 3487eb3..667e345 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 b4928bb..b7a148d 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 73b1163..7f820b8 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 c383bad..12f61ad 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 bfef0b3..7b346ec 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 543e148..de323fb 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 0e5833c..864ca28 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 46fd240..ede21fb 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 8cf5fe4..570f911 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 57a1a0e..c111fe9 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 6f7a19d..7842630 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 1ff3310..8b07875 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 572bbdf..3916a96 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 370d70b..b2dfa5c 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 f197444..f58ac38 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 af70fd6..983a753 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 85279af..b96d093 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 7bfd22e..fc205b1 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 7759d96..c24f3ff 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 6b5ca65..ffdb235 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 bc3da86..142a22a 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 43de6a8..83ab552 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 18fbfbe..c0f5c75 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 a037ac1..9c54800 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 ace5d4b..ff44734 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 83f944e..d53d05b 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 7fd9ac3..9aae0af 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 28edbae..47e8b9f 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 9a36898..d1ad8ca 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 8b0c04f..4a97e06 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 9fbde2f..6861141 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 fd27dfa..c8ea76d 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 588d1cc..88ff9fe 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 71d9478..bc3d26f 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 f3d8de2..9fba59d 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 c6cb3de..e8651c8 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 754ac30..28c9c6a 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 296c2c0..bda78b3 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 a42d356..ad37cbd 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 fea1721..4b1b983 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 1a2b04e..9da6f23 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 332cee2..98a2944 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 be1b1d4..ac8eeb1 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 96d7449..7815db5 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 97bb10d..802f04b 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 6a47d69..952dc62 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 6091722..eb4df9b 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 b16fc55..94ba23e 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 bb3a38d..6bdd03b 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 0235df9..8a8a953 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 ee93b73..1337caa 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 3b428c8..d1d76a4 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 2799fe8..89375bd 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 234e2b8..232126b 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 dd69356..d4c30d1 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 d576b54..621cd72 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/85] 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 160e86b..1264f26 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 0d6f2b3..1388edd 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 554a395..92257e3 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