diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakMap/prototype/has/returns-false-when-symbol-key-not-present.js')
-rw-r--r-- | js/src/tests/test262/built-ins/WeakMap/prototype/has/returns-false-when-symbol-key-not-present.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/has/returns-false-when-symbol-key-not-present.js b/js/src/tests/test262/built-ins/WeakMap/prototype/has/returns-false-when-symbol-key-not-present.js new file mode 100644 index 0000000000..5f379d685a --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/has/returns-false-when-symbol-key-not-present.js @@ -0,0 +1,31 @@ +// |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-weakmap.prototype.has +description: > + Return false when a Symbol key is not present in the WeakMap entries. +info: | + WeakMap.prototype.has ( _key_ ) + 6. Return *false*. +features: [Symbol, WeakMap, symbols-as-weakmap-keys] +---*/ + +var foo = Symbol('a description'); +var bar = Symbol('a description'); +var map = new WeakMap(); + +assert.sameValue(map.has(foo), false, 'Map is initially empty of regular symbol'); +assert.sameValue(map.has(Symbol.hasInstance), false, 'Map is initially empty of well-known symbol'); + +map.set(foo, 1); +assert.sameValue(map.has(bar), false, "Symbols with the same description don't alias each other"); + +map.delete(foo); +assert.sameValue(map.has(foo), false, 'Map is empty again of regular symbol after deleting'); + +map.set(Symbol.hasInstance, 2); +map.delete(Symbol.hasInstance); +assert.sameValue(map.has(Symbol.hasInstance), false, 'Map is empty again of well-known symbol after deleting'); + +reportCompare(0, 0); |