[test262] Add set method tests to staging

Reland https://crrev.com/c/4913993

This CL adds three tests from test methods tests to staging
directory with correct format.

Bug: v8:13556
Change-Id: I93817eb84e077436071dbae98bc800dd58851f91
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4983674
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Liviu Rau <liviurau@google.com>
Cr-Commit-Position: refs/heads/main@{#90645}
This commit is contained in:
Liviu Rau 2023-10-27 09:48:09 -07:00 committed by test262-pr-bot
parent 0a6dabf1e2
commit 8162f8c58f
4 changed files with 83 additions and 0 deletions

View File

@ -263,3 +263,7 @@ __setter__
IsHTMLDDA
host-gc-required
# Set methods
# https://github.com/tc39/proposal-set-methods
set-methods

View File

@ -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);

View File

@ -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);

View File

@ -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);