summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/WeakMap/prototype/set
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakMap/prototype/set')
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-object-element.js27
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-symbol-element.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js25
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js25
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js23
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js23
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js26
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this.js19
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/set.js24
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js22
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js22
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js22
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js22
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js23
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js22
-rw-r--r--js/src/tests/test262/built-ins/WeakMap/prototype/set/throw-if-key-cannot-be-held-weakly.js38
22 files changed, 502 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-object-element.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-object-element.js
new file mode 100644
index 0000000000..897b047e80
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-object-element.js
@@ -0,0 +1,27 @@
+// 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-weakmap.prototype.set
+description: >
+ Adds a value with an Object key.
+info: |
+ WeakMap.prototype.set ( _key_, _value_ )
+ 6. Let _p_ be the Record {[[Key]]: _key_, [[Value]]: _value_}.
+ 7. Append _p_ as the last element of _entries_.
+features: [WeakMap]
+---*/
+
+var map = new WeakMap();
+var foo = {};
+var bar = {};
+var baz = {};
+
+map.set(foo, 1);
+map.set(bar, 2);
+map.set(baz, 3);
+
+assert(map.has(foo));
+assert(map.has(bar));
+assert(map.has(baz));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-symbol-element.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-symbol-element.js
new file mode 100644
index 0000000000..f23ea6b54f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/adds-symbol-element.js
@@ -0,0 +1,26 @@
+// |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.set
+description: Adds a value with a Symbol key.
+info: |
+ WeakMap.prototype.set ( _key_, _value_ )
+ 6. Let _p_ be the Record {[[Key]]: _key_, [[Value]]: _value_}.
+ 7. Append _p_ as the last element of _entries_.
+features: [Symbol, WeakMap, symbols-as-weakmap-keys]
+---*/
+
+var map = new WeakMap();
+var foo = Symbol('a description');
+var bar = Symbol('a description');
+
+map.set(foo, 1);
+map.set(bar, 2);
+map.set(Symbol.hasInstance, 3);
+
+assert(map.has(bar), 'Regular symbol as key');
+assert.sameValue(map.get(foo), 1, "Symbols with the same description don't overwrite each other");
+assert(map.has(Symbol.hasInstance), 'Well-known symbol as key');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/browser.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/browser.js
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js
new file mode 100644
index 0000000000..490cbd751a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-array.js
@@ -0,0 +1,26 @@
+// 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-weakmap.prototype.set
+description: >
+ Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ ...
+ 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+ exception.
+ ...
+
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call([], {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call([], {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js
new file mode 100644
index 0000000000..d07b8f16c0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-map.js
@@ -0,0 +1,26 @@
+// 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-weakmap.prototype.set
+description: >
+ Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ ...
+ 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [Map]
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(new Map(), {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(new Map(), {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js
new file mode 100644
index 0000000000..e31e8c6be1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-object.js
@@ -0,0 +1,25 @@
+// 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-weakmap.prototype.set
+description: >
+ Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ ...
+ 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+ exception.
+ ...
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call({}, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call({}, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js
new file mode 100644
index 0000000000..5efcf091cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-set.js
@@ -0,0 +1,26 @@
+// 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-weakmap.prototype.set
+description: >
+ Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ ...
+ 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [Set]
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(new Set(), {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(new Set(), {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js
new file mode 100644
index 0000000000..e60c46b13b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js
@@ -0,0 +1,25 @@
+// 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-weakmap.prototype.set
+description: >
+ Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ ...
+ 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+ exception.
+ ...
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(WeakMap.prototype, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(WeakMap.prototype, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js
new file mode 100644
index 0000000000..052f181e53
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js
@@ -0,0 +1,23 @@
+// 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-weakmap.prototype.set
+description: WeakMap.prototype.set.length descriptor
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ WeakMap.prototype.set.length, 2,
+ 'The value of `WeakMap.prototype.set.length` is `2`'
+);
+
+verifyNotEnumerable(WeakMap.prototype.set, 'length');
+verifyNotWritable(WeakMap.prototype.set, 'length');
+verifyConfigurable(WeakMap.prototype.set, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js
new file mode 100644
index 0000000000..f1d62ffef5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js
@@ -0,0 +1,23 @@
+// 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-weakmap.prototype.set
+description: WeakMap.prototype.set.name descriptor
+info: |
+ WeakMap.prototype.set ( value )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ WeakMap.prototype.set.name, 'set',
+ 'The value of WeakMap.prototype.set.name is "set"'
+);
+
+verifyNotEnumerable(WeakMap.prototype.set, 'name');
+verifyNotWritable(WeakMap.prototype.set, 'name');
+verifyConfigurable(WeakMap.prototype.set, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js
new file mode 100644
index 0000000000..c8d6272217
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ WeakMap.prototype.set does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, WeakMap, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(WeakMap.prototype.set),
+ false,
+ 'isConstructor(WeakMap.prototype.set) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let wm = new WeakMap(); new wm.set({}, 1);
+}, '`let wm = new WeakMap(); new wm.set({}, 1)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js
new file mode 100644
index 0000000000..9f96f5e2f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this-when-ignoring-duplicate.js
@@ -0,0 +1,26 @@
+// 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-weakmap.prototype.set
+description: Returns `this` when new value is duplicate.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ ...
+ 6. Repeat for each Record {[[key]], [[value]]} p that is an element of
+ entries,
+ a. If p.[[key]] is not empty and SameValue(p.[[key]], key) is true, then
+ i. Set p.[[value]] to value.
+ ii. Return M.
+ ...
+---*/
+
+var foo = {};
+var map = new WeakMap([
+ [foo, 1]
+]);
+
+assert.sameValue(map.set(foo, 1), map, '`map.set(foo, 1)` returns `map`');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this.js
new file mode 100644
index 0000000000..dd30cc2e77
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/returns-this.js
@@ -0,0 +1,19 @@
+// 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-weakmap.prototype.set
+description: Returns `this` after setting a new value.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be this value.
+ ...
+ 9. Return M.
+
+---*/
+
+var map = new WeakMap();
+
+assert.sameValue(map.set({}, 1), map, '`map.set({}, 1)` returns `map`');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/set.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/set.js
new file mode 100644
index 0000000000..7ec5dd82c4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/set.js
@@ -0,0 +1,24 @@
+// 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-weakmap.prototype.set
+description: WeakMap.prototype.set property descriptor
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ typeof WeakMap.prototype.set,
+ 'function',
+ 'typeof WeakMap.prototype.set is "function"'
+);
+
+verifyNotEnumerable(WeakMap.prototype, 'set');
+verifyWritable(WeakMap.prototype, 'set');
+verifyConfigurable(WeakMap.prototype, 'set');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/shell.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/shell.js
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js
new file mode 100644
index 0000000000..98b2fd02f3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-boolean.js
@@ -0,0 +1,22 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(false, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(false, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js
new file mode 100644
index 0000000000..7a24860890
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-null.js
@@ -0,0 +1,22 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(null, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(null, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js
new file mode 100644
index 0000000000..1af785afca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-number.js
@@ -0,0 +1,22 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(0, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(0, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js
new file mode 100644
index 0000000000..d689e80daa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-string.js
@@ -0,0 +1,22 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call('', {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call('', {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js
new file mode 100644
index 0000000000..47522549f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-symbol.js
@@ -0,0 +1,23 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+features: [Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(Symbol(), {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(Symbol(), {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js
new file mode 100644
index 0000000000..188043687b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/this-not-object-throw-undefined.js
@@ -0,0 +1,22 @@
+// 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-weakmap.prototype.set
+description: Throws TypeError if `this` is not Object.
+info: |
+ WeakMap.prototype.set ( key, value )
+
+ 1. Let M be the this value.
+ 2. If Type(M) is not Object, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+ WeakMap.prototype.set.call(undefined, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+ var map = new WeakMap();
+ map.set.call(undefined, {}, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/throw-if-key-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/throw-if-key-cannot-be-held-weakly.js
new file mode 100644
index 0000000000..ee115dae86
--- /dev/null
+++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/throw-if-key-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-weakmap.prototype.set
+description: Throws TypeError if key cannot be held weakly.
+info: |
+ WeakMap.prototype.set ( _key_, _value_ )
+ 4. If CanBeHeldWeakly(_key_) is *false*, throw a *TypeError* exception.
+features: [Symbol, WeakMap]
+---*/
+
+var s = new WeakMap();
+
+assert.throws(TypeError, function() {
+ s.set(1, 1);
+});
+
+assert.throws(TypeError, function() {
+ s.set(false, 1);
+});
+
+assert.throws(TypeError, function() {
+ s.set(undefined, 1);
+});
+
+assert.throws(TypeError, function() {
+ s.set('string', 1);
+});
+
+assert.throws(TypeError, function() {
+ s.set(null, 1);
+});
+
+assert.throws(TypeError, function() {
+ s.set(Symbol.for('registered symbol'), 1);
+}, 'Registered symbol not allowed as WeakMap key');
+
+reportCompare(0, 0);