Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / WeakSet / iterable-with-symbol-values.js
blob217438a5c23be8341c47d509069173269c49ca8e
1 // |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-weakset-iterable
6 description: >
7   Returns the new WeakSet adding Symbol values from the iterable parameter.
8 info: |
9   WeakSet ( [ _iterable_ ] )
10   8. Repeat,
11     d. Let _status_ be Completion(Call(_adder_, _set_, « _nextValue_ »)).
13   WeakSet.prototype.add ( _value_ ):
14   6. Append _value_ as the last element of _entries_.
15 features: [Symbol, WeakSet, symbols-as-weakmap-keys]
16 includes: [compareArray.js]
17 ---*/
19 var first = Symbol('a description');
20 var second = Symbol('a description');
21 var added = [];
22 var realAdd = WeakSet.prototype.add;
23 WeakSet.prototype.add = function(value) {
24   added.push(value);
25   return realAdd.call(this, value);
27 var s = new WeakSet([first, second, Symbol.hasInstance]);
29 assert.compareArray(
30   added,
31   [first, second, Symbol.hasInstance],
32   "add() was called 3 times, on the two unregistered and one well-known symbols in order"
35 WeakSet.prototype.add = realAdd;
37 reportCompare(0, 0);