diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js')
-rw-r--r-- | js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js new file mode 100644 index 0000000000..912b4ac58a --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakRef/throws-when-target-cannot-be-held-weakly.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weak-ref-target +description: > + Throws a TypeError if target cannot be held weakly +info: | + WeakRef ( _target_ ) + 2. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception. +features: [WeakRef] +---*/ + +assert.sameValue( + typeof WeakRef, 'function', + 'typeof WeakRef is function' +); + +assert.throws(TypeError, function() { + new WeakRef(); +}, 'implicit undefined'); + +assert.throws(TypeError, function() { + new WeakRef(undefined); +}, 'explicit undefined'); + +assert.throws(TypeError, function() { + new WeakRef(null); +}, 'null'); + +assert.throws(TypeError, function() { + new WeakRef(1); +}, 'number'); + +assert.throws(TypeError, function() { + new WeakRef('Object'); +}, 'string'); + +var s = Symbol.for('registered symbol'); +assert.throws(TypeError, function() { + new WeakRef(s); +}, 'registered symbol'); + +assert.throws(TypeError, function() { + new WeakRef(true); +}, 'Boolean, true'); + +assert.throws(TypeError, function() { + new WeakRef(false); +}, 'Boolean, false'); + +reportCompare(0, 0); |