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

[test262] Add set method tests to staging #3949

Closed
wants to merge 1 commit 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
31 changes: 31 additions & 0 deletions test/staging/set-methods/set-intersect-other-is-set-like.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: test intersection method when `other` is a set-like.
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);
24 changes: 24 additions & 0 deletions test/staging/set-methods/set-intersection-other-is-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: test intersection method when `other` is a map.
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);
24 changes: 24 additions & 0 deletions test/staging/set-methods/set-intersection-other-is-set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2023 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: test intersection method when `other` is a set.
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);