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.
5 esid: sec-set.prototype.symmetricdifference
6 description: Set.prototype.symmetricDifference works on subclasses of Set, but never calls the receiver's size/has/keys methods
7 features: [set-methods]
8 includes: [compareArray.js]
15 class MySet extends Set {
18 return super.size(...rest);
23 return super.has(...rest);
28 return super.keys(...rest);
32 const s1 = new MySet([1, 2]);
33 const s2 = new Set([2, 3]);
34 const expected = [1, 3];
35 const combined = s1.symmetricDifference(s2);
37 assert.compareArray([...combined], expected);
38 assert.sameValue(combined instanceof Set, true, "The returned object is a Set");
40 combined instanceof MySet,
42 "The returned object is a Set, not a subclass"
44 assert.sameValue(sizeCount, 0, "size should not be called on the receiver");
45 assert.sameValue(hasCount, 0, "has should not be called on the receiver");
46 assert.sameValue(keysCount, 0, "keys should not be called on the receiver");