mirror of https://github.com/tc39/test262.git
[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:
parent
0a6dabf1e2
commit
8162f8c58f
|
@ -263,3 +263,7 @@ __setter__
|
|||
|
||||
IsHTMLDDA
|
||||
host-gc-required
|
||||
|
||||
# Set methods
|
||||
# https://github.com/tc39/proposal-set-methods
|
||||
set-methods
|
||||
|
|
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
Loading…
Reference in New Issue