Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Set / prototype / symmetricDifference / allows-set-like-class.js
blob939c73916aa6b42da7740dc00ac7cde09ef5a806
1 // |reftest| skip -- set-methods is not supported
2 // Copyright (C) 2023 Anthony Frehner and Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-set.prototype.symmetricdifference
6 description: GetSetRecord allows instances of Set-like classes
7 info: |
8     1. If obj is not an Object, throw a TypeError exception.
9     2. Let rawSize be ? Get(obj, "size").
10     ...
11     7. Let has be ? Get(obj, "has").
12     ...
13     9. Let keys be ? Get(obj, "keys").
14 features: [set-methods]
15 includes: [compareArray.js]
16 ---*/
18 const s1 = new Set([1, 2]);
19 const s2 = new class {
20   get size() {
21     return 2;
22   }
23   has(v) {
24     throw new Test262Error("Set.prototype.symmetricDifference should not invoke .has on its argument");
25   }
26   * keys() {
27     yield 2;
28     yield 3;
29   }
31 const expected = [1, 3];
32 const combined = s1.symmetricDifference(s2);
34 assert.compareArray([...combined], expected);
35 assert.sameValue(combined instanceof Set, true, "The returned object is a Set");
37 reportCompare(0, 0);