summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js')
-rw-r--r--js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js
new file mode 100644
index 0000000000..d92f3a283b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-weakset.prototype.add
+description: Throws TypeError if value cannot be held weakly.
+info: |
+ WeakSet.prototype.add ( _value_ )
+ 3. If CanBeHeldWeakly(_value_) is *false*, throw a *TypeError* exception.
+features: [Symbol, WeakSet]
+---*/
+
+var s = new WeakSet();
+
+assert.throws(TypeError, function() {
+ s.add(1);
+});
+
+assert.throws(TypeError, function() {
+ s.add(false);
+});
+
+assert.throws(TypeError, function() {
+ s.add();
+});
+
+assert.throws(TypeError, function() {
+ s.add('string');
+});
+
+assert.throws(TypeError, function() {
+ s.add(null);
+});
+
+assert.throws(TypeError, function() {
+ s.add(Symbol.for('registered symbol'));
+}, 'Registered symbol not allowed as WeakSet value');
+
+reportCompare(0, 0);