Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update two Array.fromAsync this-constructor tests to test the correct behavior #3925

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ asyncTest(async function () {

// Note https://github.com/tc39/proposal-array-from-async/issues/35
const expectedCallsForArrayLike = [
"construct MyArray",
"construct MyArray",
"defineProperty A[0]",
"defineProperty A[1]",
Expand Down
5 changes: 2 additions & 3 deletions test/built-ins/Array/fromAsync/this-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ asyncTest(async function () {
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, 2, "constructor is called twice");
assert.compareArray(constructorCalls[0], [], "constructor is called first with no arguments");
assert.compareArray(constructorCalls[1], [2], "constructor is called second with a length argument");
assert.sameValue(constructorCalls.length, 1, "constructor is called once");
assert.compareArray(constructorCalls[0], [2], "constructor is called with a length argument");
});
23 changes: 23 additions & 0 deletions test/staging/SetMethods/set-intersection-other-is-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
features: [set-methods]
includes: [compareArray.js]
---*/

const firstSet = new Set();
firstSet.add(42);
firstSet.add(43);

const other = new Map();
other.set(42);
other.set(46);
other.set(47);

const resultSet = new Set();
resultSet.add(42);

const resultArray = Array.from(resultSet);
const intersectionArray = Array.from(firstSet.intersection(other));

assert.compareArray(resultArray, intersectionArray);
30 changes: 30 additions & 0 deletions test/staging/SetMethods/set-intersection-other-is-set-like.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
features: [set-methods]
includes: [compareArray.js]
---*/

const SetLike = {
arr: [42, 43, 45],
size: 3,
keys() {
return this.arr[Symbol.iterator]();
},
has(key) {
return this.arr.indexOf(key) != -1;
}
};

const firstSet = new Set();
firstSet.add(42);
firstSet.add(43);

const resultSet = new Set();
resultSet.add(42);
resultSet.add(43);

const resultArray = Array.from(resultSet);
const intersectionArray = Array.from(firstSet.intersection(SetLike));

assert.compareArray(resultArray, intersectionArray);
23 changes: 23 additions & 0 deletions test/staging/SetMethods/set-intersection-other-is-set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
features: [set-methods]
includes: [compareArray.js]
---*/

const firstSet = new Set();
firstSet.add(42);
firstSet.add(43);
firstSet.add(44);

const otherSet = new Set();
otherSet.add(42);
otherSet.add(45);

const resultSet = new Set();
resultSet.add(42);

const resultArray = Array.from(resultSet);
const intersectionArray = Array.from(firstSet.intersection(otherSet));

assert.compareArray(resultArray, intersectionArray);