From f0ec4e6de19c27163686fce45c72214af50a2bc4 Mon Sep 17 00:00:00 2001
From: Leonardo Balter <leonardo.balter@gmail.com>
Date: Wed, 1 Jul 2015 11:58:01 -0400
Subject: [PATCH] WeakMap - core tests

---
 test/built-ins/WeakMap/constructor.js         | 13 ++++
 test/built-ins/WeakMap/empty-iterable.js      | 31 ++++++++
 .../WeakMap/get-set-method-failure.js         | 30 ++++++++
 test/built-ins/WeakMap/iterable-failure.js    | 19 +++++
 test/built-ins/WeakMap/iterable.js            | 37 ++++++++++
 .../iterator-close-after-set-failure.js       | 37 ++++++++++
 ...terator-item-first-entry-returns-abrupt.js | 47 ++++++++++++
 ...erator-item-second-entry-returns-abrupt.js | 47 ++++++++++++
 ...tor-items-are-not-object-close-iterator.js | 72 +++++++++++++++++++
 .../WeakMap/iterator-items-are-not-object.js  | 48 +++++++++++++
 .../WeakMap/iterator-next-failure.js          | 28 ++++++++
 .../WeakMap/iterator-value-failure.js         | 34 +++++++++
 test/built-ins/WeakMap/length.js              | 14 ++++
 test/built-ins/WeakMap/name.js                | 20 ++++++
 test/built-ins/WeakMap/no-iterable.js         | 24 +++++++
 .../WeakMap/properties-of-map-instances.js    | 14 ++++
 ...perties-of-the-weakmap-prototype-object.js | 20 ++++++
 .../built-ins/WeakMap/prototype-of-weakmap.js | 14 ++++
 .../WeakMap/set-not-callable-throws.js        | 25 +++++++
 .../symbol-disallowed-as-weakmap-key.js       | 14 ----
 test/built-ins/WeakMap/undefined-newtarget.js | 19 +++++
 test/built-ins/WeakMap/weakmap.js             | 14 ++++
 22 files changed, 607 insertions(+), 14 deletions(-)
 create mode 100644 test/built-ins/WeakMap/constructor.js
 create mode 100644 test/built-ins/WeakMap/empty-iterable.js
 create mode 100644 test/built-ins/WeakMap/get-set-method-failure.js
 create mode 100644 test/built-ins/WeakMap/iterable-failure.js
 create mode 100644 test/built-ins/WeakMap/iterable.js
 create mode 100644 test/built-ins/WeakMap/iterator-close-after-set-failure.js
 create mode 100644 test/built-ins/WeakMap/iterator-item-first-entry-returns-abrupt.js
 create mode 100644 test/built-ins/WeakMap/iterator-item-second-entry-returns-abrupt.js
 create mode 100644 test/built-ins/WeakMap/iterator-items-are-not-object-close-iterator.js
 create mode 100644 test/built-ins/WeakMap/iterator-items-are-not-object.js
 create mode 100644 test/built-ins/WeakMap/iterator-next-failure.js
 create mode 100644 test/built-ins/WeakMap/iterator-value-failure.js
 create mode 100644 test/built-ins/WeakMap/length.js
 create mode 100644 test/built-ins/WeakMap/name.js
 create mode 100644 test/built-ins/WeakMap/no-iterable.js
 create mode 100644 test/built-ins/WeakMap/properties-of-map-instances.js
 create mode 100644 test/built-ins/WeakMap/properties-of-the-weakmap-prototype-object.js
 create mode 100644 test/built-ins/WeakMap/prototype-of-weakmap.js
 create mode 100644 test/built-ins/WeakMap/set-not-callable-throws.js
 delete mode 100644 test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js
 create mode 100644 test/built-ins/WeakMap/undefined-newtarget.js
 create mode 100644 test/built-ins/WeakMap/weakmap.js

diff --git a/test/built-ins/WeakMap/constructor.js b/test/built-ins/WeakMap/constructor.js
new file mode 100644
index 0000000000..90a3ab6eaf
--- /dev/null
+++ b/test/built-ins/WeakMap/constructor.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1
+description: >
+  The WeakMap constructor is the %WeakMap% intrinsic object and the initial
+  value of the WeakMap property of the global object.
+---*/
+
+assert.sameValue(
+  typeof WeakMap, 'function',
+  'typeof WeakMap is "function"'
+);
diff --git a/test/built-ins/WeakMap/empty-iterable.js b/test/built-ins/WeakMap/empty-iterable.js
new file mode 100644
index 0000000000..045e2df5bc
--- /dev/null
+++ b/test/built-ins/WeakMap/empty-iterable.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  If the iterable argument is empty, return new WeakMap object.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    a. Let next be IteratorStep(iter).
+    b. ReturnIfAbrupt(next).
+    c. If next is false, return map.
+  ...
+---*/
+
+var counter = 0;
+var set = WeakMap.prototype.set;
+WeakMap.prototype.set = function(value) {
+  counter++;
+  return set.call(this, value);
+};
+var map = new WeakMap([]);
+
+assert.sameValue(Object.getPrototypeOf(map), WeakMap.prototype);
+assert(map instanceof WeakMap);
+assert.sameValue(
+  counter, 0,
+  'empty iterable does not call WeakMap.prototype.set'
+);
diff --git a/test/built-ins/WeakMap/get-set-method-failure.js b/test/built-ins/WeakMap/get-set-method-failure.js
new file mode 100644
index 0000000000..b24a300691
--- /dev/null
+++ b/test/built-ins/WeakMap/get-set-method-failure.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Return abrupt after getting `set` method.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  5. If iterable is not present, let iterable be undefined.
+  6. If iterable is either undefined or null, let iter be undefined.
+  7. Else,
+    a. Let adder be Get(map, "set").
+    b. ReturnIfAbrupt(adder).
+    ...
+---*/
+
+Object.defineProperty(WeakMap.prototype, 'set', {
+  get: function() {
+    throw new Test262Error();
+  }
+});
+
+new WeakMap();
+new WeakMap(null);
+
+assert.throws(Test262Error, function() {
+  new WeakMap([]);
+});
diff --git a/test/built-ins/WeakMap/iterable-failure.js b/test/built-ins/WeakMap/iterable-failure.js
new file mode 100644
index 0000000000..f28e5a9b91
--- /dev/null
+++ b/test/built-ins/WeakMap/iterable-failure.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.
+/*---
+es6id: 23.3.1.1
+description: >
+  If the iterable argument is undefined, return new WeakMap object.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  7. Else,
+    d. Let iter be GetIterator(iterable).
+    e. ReturnIfAbrupt(iter).
+  ...
+---*/
+
+assert.throws(TypeError, function() {
+  new WeakMap({});
+});
diff --git a/test/built-ins/WeakMap/iterable.js b/test/built-ins/WeakMap/iterable.js
new file mode 100644
index 0000000000..c964e0e6d0
--- /dev/null
+++ b/test/built-ins/WeakMap/iterable.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Returns the new WeakMap adding the objects from the iterable parameter.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
+    l. If status is an abrupt completion, return IteratorClose(iter, status).
+includes: [compareArray.js]
+---*/
+
+var first = {};
+var second = {};
+var results = [];
+var set = WeakMap.prototype.set;
+WeakMap.prototype.set = function(key, value) {
+  results.push({
+    _this: this,
+    key: key,
+    value: value
+  });
+  return set.call(this, key, value);
+};
+var map = new WeakMap([[first, 42], [second, 43]]);
+
+assert.sameValue(results.length, 2, 'Called WeakMap#set for each object');
+assert.sameValue(results[0].key, first, 'Adds object in order - first key');
+assert.sameValue(results[0].value, 42, 'Adds object in order - first value');
+assert.sameValue(results[0]._this, map, 'Adds object in order - this');
+assert.sameValue(results[1].key, second, 'Adds object in order - second key');
+assert.sameValue(results[1].value, 43, 'Adds object in order - second value');
+assert.sameValue(results[1]._this, map, 'Adds object in order - this');
diff --git a/test/built-ins/WeakMap/iterator-close-after-set-failure.js b/test/built-ins/WeakMap/iterator-close-after-set-failure.js
new file mode 100644
index 0000000000..c4597f76b2
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-close-after-set-failure.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Return IteratorClose(iter, status) if fail on adding value on constructing.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
+    l. If status is an abrupt completion, return IteratorClose(iter, status).
+---*/
+
+var count = 0;
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return { value: [], done: false };
+    },
+    return: function() {
+      count += 1;
+    }
+  };
+};
+WeakMap.prototype.set = function() { throw new Test262Error(); };
+
+assert.throws(Test262Error, function() {
+  new WeakMap(iterable);
+});
+
+assert.sameValue(
+  count, 1,
+  'The iterator is closed when `WeakMap.prototype.set` throws an error.'
+);
diff --git a/test/built-ins/WeakMap/iterator-item-first-entry-returns-abrupt.js b/test/built-ins/WeakMap/iterator-item-first-entry-returns-abrupt.js
new file mode 100644
index 0000000000..e3b9a017ba
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-item-first-entry-returns-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Closes iterator if item first entry completes abruptly.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    ...
+    d. Let nextItem be IteratorValue(next).
+    ...
+    g. Let k be Get(nextItem, "0").
+    h. If k is an abrupt completion, return IteratorClose(iter, k).
+    ...
+features: [Symbol.iterator]
+---*/
+
+var count = 0;
+var item = ['foo', 'bar'];
+Object.defineProperty(item, 0, {
+  get: function() {
+    throw new Test262Error();
+  }
+});
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return {
+        value: item,
+        done: false
+      };
+    },
+    return: function() {
+      count++;
+    }
+  };
+};
+
+assert.throws(Test262Error, function() {
+  new WeakMap(iterable);
+});
+
+assert.sameValue(count, 1, 'The get error closed the iterator');
diff --git a/test/built-ins/WeakMap/iterator-item-second-entry-returns-abrupt.js b/test/built-ins/WeakMap/iterator-item-second-entry-returns-abrupt.js
new file mode 100644
index 0000000000..a3e0c83e43
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-item-second-entry-returns-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Closes iterator if item second entry completes abruptly.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    ...
+    d. Let nextItem be IteratorValue(next).
+    ...
+    i. Let v be Get(nextItem, "1").
+    j. If v is an abrupt completion, return IteratorClose(iter, v).
+    ...
+features: [Symbol.iterator]
+---*/
+
+var count = 0;
+var item = ['foo', 'bar'];
+Object.defineProperty(item, 1, {
+  get: function() {
+    throw new Test262Error();
+  }
+});
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return {
+        value: item,
+        done: false
+      };
+    },
+    return: function() {
+      count++;
+    }
+  };
+};
+
+assert.throws(Test262Error, function() {
+  new WeakMap(iterable);
+});
+
+assert.sameValue(count, 1, 'The get error closed the iterator');
diff --git a/test/built-ins/WeakMap/iterator-items-are-not-object-close-iterator.js b/test/built-ins/WeakMap/iterator-items-are-not-object-close-iterator.js
new file mode 100644
index 0000000000..b50834448e
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-items-are-not-object-close-iterator.js
@@ -0,0 +1,72 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Closes the iterator object after not object error on next item.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    ...
+    d. Let nextItem be IteratorValue(next).
+    e. ReturnIfAbrupt(nextItem).
+    f. If Type(nextItem) is not Object,
+      i. Let error be Completion{[[type]]: throw, [[value]]: a newly created
+      TypeError object, [[target]]:empty}.
+      ii. Return IteratorClose(iter, error).
+features:
+  - Symbol
+  - Symbol.iterator
+---*/
+
+var count = 0;
+var nextItem;
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return { value: nextItem, done: false };
+    },
+    return: function() {
+      count += 1;
+    }
+  };
+};
+
+nextItem = 1;
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 1);
+
+nextItem = true;
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 2);
+
+nextItem = '';
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 3);
+
+nextItem = null;
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 4);
+
+nextItem = undefined;
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 5);
+
+nextItem = Symbol('a');
+assert.throws(TypeError, function() {
+  new WeakMap(iterable);
+});
+assert.sameValue(count, 6);
diff --git a/test/built-ins/WeakMap/iterator-items-are-not-object.js b/test/built-ins/WeakMap/iterator-items-are-not-object.js
new file mode 100644
index 0000000000..be1904a66c
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-items-are-not-object.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Throws a TypeError if iterable itens are not Objects.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    ...
+    d. Let nextItem be IteratorValue(next).
+    e. ReturnIfAbrupt(nextItem).
+    f. If Type(nextItem) is not Object,
+      i. Let error be Completion{[[type]]: throw, [[value]]: a newly created
+      TypeError object, [[target]]:empty}.
+      ii. Return IteratorClose(iter, error).
+features: [Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+  new WeakMap([1, 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap(['', 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap([true, 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap([null, 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap([Symbol('a'), 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap([undefined, 1]);
+});
+
+assert.throws(TypeError, function() {
+  new WeakMap([['a', 1], 2]);
+});
diff --git a/test/built-ins/WeakMap/iterator-next-failure.js b/test/built-ins/WeakMap/iterator-next-failure.js
new file mode 100644
index 0000000000..cb084f0907
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-next-failure.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  Return abrupt from next iterator step.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    a. Let next be IteratorStep(iter).
+    b. ReturnIfAbrupt(next).
+    ...
+---*/
+
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      throw new Test262Error();
+    }
+  };
+};
+
+assert.throws(Test262Error, function() {
+  new WeakMap(iterable);
+});
diff --git a/test/built-ins/WeakMap/iterator-value-failure.js b/test/built-ins/WeakMap/iterator-value-failure.js
new file mode 100644
index 0000000000..7a0626dd42
--- /dev/null
+++ b/test/built-ins/WeakMap/iterator-value-failure.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  If the iterable argument is empty, return new WeakMap object.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  9. Repeat
+    ...
+    d. Let nextItem be IteratorValue(next).
+    e. ReturnIfAbrupt(nextItem).
+    ...
+---*/
+
+var iterable = {};
+iterable[Symbol.iterator] = function() {
+  return {
+    next: function() {
+      return {
+        get value() {
+          throw new Test262Error();
+        },
+        done: false
+      };
+    }
+  };
+};
+
+assert.throws(Test262Error, function() {
+  new WeakMap(iterable);
+});
diff --git a/test/built-ins/WeakMap/length.js b/test/built-ins/WeakMap/length.js
new file mode 100644
index 0000000000..2db93622b8
--- /dev/null
+++ b/test/built-ins/WeakMap/length.js
@@ -0,0 +1,14 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.2
+description: >
+  The length property of the WeakMap constructor is 0.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(WeakMap.length, 0, 'The value of `WeakMap.length` is `0`');
+
+verifyNotEnumerable(WeakMap, 'length');
+verifyNotWritable(WeakMap, 'length');
+verifyConfigurable(WeakMap, 'length');
diff --git a/test/built-ins/WeakMap/name.js b/test/built-ins/WeakMap/name.js
new file mode 100644
index 0000000000..75d24e2bbc
--- /dev/null
+++ b/test/built-ins/WeakMap/name.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+    WeakMap ( [ iterable ] )
+
+    17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+    WeakMap.name, 'WeakMap',
+    'The value of `WeakMap.name` is "WeakMap"'
+);
+
+verifyNotEnumerable(WeakMap, 'name');
+verifyNotWritable(WeakMap, 'name');
+verifyConfigurable(WeakMap, 'name');
diff --git a/test/built-ins/WeakMap/no-iterable.js b/test/built-ins/WeakMap/no-iterable.js
new file mode 100644
index 0000000000..229a28fde2
--- /dev/null
+++ b/test/built-ins/WeakMap/no-iterable.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.
+/*---
+es6id: 23.3.1.1
+description: >
+  If the iterable argument is undefined, return new WeakMap object.
+info: >
+  WeakMap ( [ iterable ] )
+
+  ...
+  5. If iterable is not present, let iterable be undefined.
+  6. If iterable is either undefined or null, let iter be undefined.
+  ...
+  8. If iter is undefined, return map.
+  ...
+---*/
+
+var a = new WeakMap();
+var b = new WeakMap(undefined);
+var c = new WeakMap(null);
+
+assert.sameValue(Object.getPrototypeOf(a), WeakMap.prototype);
+assert.sameValue(Object.getPrototypeOf(b), WeakMap.prototype);
+assert.sameValue(Object.getPrototypeOf(c), WeakMap.prototype);
diff --git a/test/built-ins/WeakMap/properties-of-map-instances.js b/test/built-ins/WeakMap/properties-of-map-instances.js
new file mode 100644
index 0000000000..f928f0bec4
--- /dev/null
+++ b/test/built-ins/WeakMap/properties-of-map-instances.js
@@ -0,0 +1,14 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.4
+description: >
+  WeakMap instances are ordinary objects that inherit properties from the
+  WeakMap prototype.
+---*/
+
+assert.sameValue(
+  Object.getPrototypeOf(new WeakMap()),
+  WeakMap.prototype,
+  '`Object.getPrototypeOf(new WeakMap())` returns `WeakMap.prototype`'
+);
diff --git a/test/built-ins/WeakMap/properties-of-the-weakmap-prototype-object.js b/test/built-ins/WeakMap/properties-of-the-weakmap-prototype-object.js
new file mode 100644
index 0000000000..bebb9f9454
--- /dev/null
+++ b/test/built-ins/WeakMap/properties-of-the-weakmap-prototype-object.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.3
+description: >
+  The WeakMap.prototype's prototype is Object.prototype.
+info: >
+  23.3.3 Properties of the WeakMap Prototype Object
+
+  The WeakMap prototype object is the intrinsic object %WeakMapPrototype%. The
+  value of the [[Prototype]] internal slot of the WeakMap prototype object is
+  the intrinsic object %ObjectPrototype% (19.1.3). The WeakMap prototype object
+  is an ordinary object. It does not have a [[WeakMapData]] internal slot.
+---*/
+
+assert.sameValue(
+  Object.getPrototypeOf(WeakMap.prototype),
+  Object.prototype,
+  '`Object.getPrototypeOf(WeakMap.prototype)` returns `Object.prototype`'
+);
diff --git a/test/built-ins/WeakMap/prototype-of-weakmap.js b/test/built-ins/WeakMap/prototype-of-weakmap.js
new file mode 100644
index 0000000000..c93853eb23
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype-of-weakmap.js
@@ -0,0 +1,14 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.2
+description: >
+  The value of the [[Prototype]] internal slot of the WeakMap constructor is the
+  intrinsic object %FunctionPrototype% (19.2.3).
+---*/
+
+assert.sameValue(
+  Object.getPrototypeOf(WeakMap),
+  Function.prototype,
+  '`Object.getPrototypeOf(WeakMap)` returns `Function.prototype`'
+);
diff --git a/test/built-ins/WeakMap/set-not-callable-throws.js b/test/built-ins/WeakMap/set-not-callable-throws.js
new file mode 100644
index 0000000000..db6c76586a
--- /dev/null
+++ b/test/built-ins/WeakMap/set-not-callable-throws.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.
+/*---
+es6id: 23.3.1.1
+description: >
+  Throws TypeError if add is not callable on constructor call.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  ...
+  5. If iterable is not present, let iterable be undefined.
+  6. If iterable is either undefined or null, let iter be undefined.
+  7. Else,
+    a. Let adder be Get(map, "set").
+    b. ReturnIfAbrupt(adder).
+    c. If IsCallable(adder) is false, throw a TypeError exception.
+  ...
+---*/
+
+WeakMap.prototype.set = null;
+new WeakMap();
+
+assert.throws(TypeError, function() {
+  new WeakMap([]);
+});
diff --git a/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js b/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js
deleted file mode 100644
index 4ed39dfe5a..0000000000
--- a/test/built-ins/WeakMap/symbol-disallowed-as-weakmap-key.js
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) Copyright 2013 the V8 project authors. All rights reserved.
-// This code is governed by the BSD license found in the LICENSE file.
-/*---
-es6id: 23.3.3.5_S2
-description: >
-    Symbol may not be used as a WeakMap key
-features: [WeakMap]
----*/
-var weakmap = new WeakMap();
-var sym = Symbol();
-
-assert.throws(TypeError, function() {
-  weakmap.set(sym, 1);
-});
diff --git a/test/built-ins/WeakMap/undefined-newtarget.js b/test/built-ins/WeakMap/undefined-newtarget.js
new file mode 100644
index 0000000000..d7b5b1bd13
--- /dev/null
+++ b/test/built-ins/WeakMap/undefined-newtarget.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.
+/*---
+es6id: 23.3.1.1
+description: >
+  Throws a TypeError if NewTarget is undefined.
+info: >
+  23.3.1.1 WeakMap ( [ iterable ] )
+
+  1. If NewTarget is undefined, throw a TypeError exception.
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap();
+});
+
+assert.throws(TypeError, function() {
+  WeakMap([]);
+});
diff --git a/test/built-ins/WeakMap/weakmap.js b/test/built-ins/WeakMap/weakmap.js
new file mode 100644
index 0000000000..6a67915180
--- /dev/null
+++ b/test/built-ins/WeakMap/weakmap.js
@@ -0,0 +1,14 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 23.3.1.1
+description: >
+  WeakMap ( [ iterable ] )
+
+  17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+---*/
+
+verifyNotEnumerable(this, 'WeakMap');
+verifyWritable(this, 'WeakMap');
+verifyConfigurable(this, 'WeakMap');
-- 
GitLab