diff options
Diffstat (limited to 'js/src/tests/test262/staging/set-methods')
5 files changed, 88 insertions, 0 deletions
diff --git a/js/src/tests/test262/staging/set-methods/browser.js b/js/src/tests/test262/staging/set-methods/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/set-methods/browser.js diff --git a/js/src/tests/test262/staging/set-methods/set-intersect-other-is-set-like.js b/js/src/tests/test262/staging/set-methods/set-intersect-other-is-set-like.js new file mode 100644 index 0000000000..8d31996491 --- /dev/null +++ b/js/src/tests/test262/staging/set-methods/set-intersect-other-is-set-like.js @@ -0,0 +1,34 @@ +// |reftest| skip -- set-methods is not supported +// 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); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/set-methods/set-intersection-other-is-map.js b/js/src/tests/test262/staging/set-methods/set-intersection-other-is-map.js new file mode 100644 index 0000000000..e53671fa8a --- /dev/null +++ b/js/src/tests/test262/staging/set-methods/set-intersection-other-is-map.js @@ -0,0 +1,27 @@ +// |reftest| skip -- set-methods is not supported +// 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); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/set-methods/set-intersection-other-is-set.js b/js/src/tests/test262/staging/set-methods/set-intersection-other-is-set.js new file mode 100644 index 0000000000..b2cb955a11 --- /dev/null +++ b/js/src/tests/test262/staging/set-methods/set-intersection-other-is-set.js @@ -0,0 +1,27 @@ +// |reftest| skip -- set-methods is not supported +// 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); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/set-methods/shell.js b/js/src/tests/test262/staging/set-methods/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/set-methods/shell.js |