diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js')
-rw-r--r-- | js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js b/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js new file mode 100644 index 0000000000..217438a5c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js @@ -0,0 +1,37 @@ +// |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 +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset-iterable +description: > + Returns the new WeakSet adding Symbol values from the iterable parameter. +info: | + WeakSet ( [ _iterable_ ] ) + 8. Repeat, + d. Let _status_ be Completion(Call(_adder_, _set_, « _nextValue_ »)). + + WeakSet.prototype.add ( _value_ ): + 6. Append _value_ as the last element of _entries_. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +includes: [compareArray.js] +---*/ + +var first = Symbol('a description'); +var second = Symbol('a description'); +var added = []; +var realAdd = WeakSet.prototype.add; +WeakSet.prototype.add = function(value) { + added.push(value); + return realAdd.call(this, value); +}; +var s = new WeakSet([first, second, Symbol.hasInstance]); + +assert.compareArray( + added, + [first, second, Symbol.hasInstance], + "add() was called 3 times, on the two unregistered and one well-known symbols in order" +); + +WeakSet.prototype.add = realAdd; + +reportCompare(0, 0); |