From 0887df4c67259f301ada446ad3a23bd45df7fab8 Mon Sep 17 00:00:00 2001
From: Leonardo Balter <leonardo.balter@gmail.com>
Date: Wed, 1 Jul 2015 15:03:48 -0400
Subject: [PATCH] WeakMap.prototype.has

---
 ...ot-have-weakmapdata-internal-slot-array.js | 23 +++++++++++++++++
 ...-not-have-weakmapdata-internal-slot-map.js | 24 ++++++++++++++++++
 ...t-have-weakmapdata-internal-slot-object.js | 23 +++++++++++++++++
 ...-not-have-weakmapdata-internal-slot-set.js | 24 ++++++++++++++++++
 ...mapdata-internal-slot-weakmap-prototype.js | 23 +++++++++++++++++
 test/built-ins/WeakMap/prototype/has/has.js   | 23 +++++++++++++++++
 .../built-ins/WeakMap/prototype/has/length.js | 22 ++++++++++++++++
 test/built-ins/WeakMap/prototype/has/name.js  | 22 ++++++++++++++++
 .../returns-false-when-value-is-not-object.js | 21 ++++++++++++++++
 .../returns-false-when-value-not-present.js   | 25 +++++++++++++++++++
 .../has/returns-true-when-value-present.js    | 22 ++++++++++++++++
 .../has/this-not-object-throw-boolean.js      | 21 ++++++++++++++++
 .../has/this-not-object-throw-null.js         | 20 +++++++++++++++
 .../has/this-not-object-throw-number.js       | 20 +++++++++++++++
 .../has/this-not-object-throw-string.js       | 20 +++++++++++++++
 .../has/this-not-object-throw-symbol.js       | 21 ++++++++++++++++
 .../has/this-not-object-throw-undefined.js    | 20 +++++++++++++++
 17 files changed, 374 insertions(+)
 create mode 100644 test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/has.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/length.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/name.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
 create mode 100644 test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js

diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.js
new file mode 100644
index 0000000000..33dc84e342
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-array.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+  exception.
+  ...
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call([], {}, 1);
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call([], {}, 1);
+});
diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.js
new file mode 100644
index 0000000000..5fd060eac7
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-map.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.3.4
+description: >
+  Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+  exception.
+  ...
+features: [Map]
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call(new Map(), {}, 1);
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(new Map(), {}, 1);
+});
diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.js
new file mode 100644
index 0000000000..013b247870
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-object.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+  exception.
+  ...
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call({}, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call({}, {}, 1);
+});
diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-set.js
new file mode 100644
index 0000000000..1f9bb68aee
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-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.
+/*---
+es6id: 23.3.3.4
+description: >
+  Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+  exception.
+  ...
+features: [Set]
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call(new Set(), {}, 1);
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(new Set(), {}, 1);
+});
diff --git a/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.js
new file mode 100644
index 0000000000..297b9da183
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/does-not-have-weakmapdata-internal-slot-weakmap-prototype.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  Throws TypeError if `this` doesn't have a [[WeakMapData]] internal slot.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError
+  exception.
+  ...
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call(WeakMap.prototype, {}, 1);
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(WeakMap.prototype, {}, 1);
+});
diff --git a/test/built-ins/WeakMap/prototype/has/has.js b/test/built-ins/WeakMap/prototype/has/has.js
new file mode 100644
index 0000000000..9567bb7cf7
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/has.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  WeakMap.prototype.has property descriptor
+info: >
+  WeakMap.prototype.has ( value )
+
+  17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+  typeof WeakMap.prototype.has,
+  'function',
+  'typeof WeakMap.prototype.has is "function"'
+);
+
+verifyNotEnumerable(WeakMap.prototype, 'has');
+verifyWritable(WeakMap.prototype, 'has');
+verifyConfigurable(WeakMap.prototype, 'has');
diff --git a/test/built-ins/WeakMap/prototype/has/length.js b/test/built-ins/WeakMap/prototype/has/length.js
new file mode 100644
index 0000000000..17291222b9
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/length.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  WeakMap.prototype.has.length value and writability.
+info: >
+  WeakMap.prototype.has ( value )
+
+  17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+  WeakMap.prototype.has.length, 1,
+  'The value of WeakMap.prototype.has.length is 1'
+);
+
+verifyNotEnumerable(WeakMap.prototype.has, 'length');
+verifyNotWritable(WeakMap.prototype.has, 'length');
+verifyConfigurable(WeakMap.prototype.has, 'length');
diff --git a/test/built-ins/WeakMap/prototype/has/name.js b/test/built-ins/WeakMap/prototype/has/name.js
new file mode 100644
index 0000000000..04c7c0e0fd
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/name.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  WeakMap.prototype.has.name value and writability.
+info: >
+  WeakMap.prototype.has ( value )
+
+  17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+  WeakMap.prototype.has.name, 'has',
+  'The value of WeakMap.prototype.has.name is "has"'
+);
+
+verifyNotEnumerable(WeakMap.prototype.has, 'name');
+verifyNotWritable(WeakMap.prototype.has, 'name');
+verifyConfigurable(WeakMap.prototype.has, 'name');
diff --git a/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
new file mode 100644
index 0000000000..e721e15069
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-is-not-object.js
@@ -0,0 +1,21 @@
+// 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.4
+description: >
+  Returns false if value is not an Object.
+info: >
+  WeakMap.prototype.has ( value )
+
+  5. If Type(key) is not Object, return false.
+features: [Symbol]
+---*/
+
+var map = new WeakMap();
+
+assert.sameValue(map.has(1), false);
+assert.sameValue(map.has(''), false);
+assert.sameValue(map.has(null), false);
+assert.sameValue(map.has(undefined), false);
+assert.sameValue(map.has(true), false);
+assert.sameValue(map.has(Symbol()), false);
diff --git a/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.js
new file mode 100644
index 0000000000..adce12027d
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/returns-false-when-value-not-present.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.3.4
+description: >
+  Return false when value is not present in the WeakMap entries.
+info: >
+  WeakMap.prototype.has ( value )
+
+  ...
+  7. Return false.
+
+---*/
+
+var foo = {};
+var bar = {};
+var map = new WeakMap();
+
+assert.sameValue(map.has(foo), false);
+
+map.set(foo, 1);
+assert.sameValue(map.has(bar), false);
+
+map.delete(foo);
+assert.sameValue(map.has(foo), false);
diff --git a/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js b/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.js
new file mode 100644
index 0000000000..07724ea278
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/returns-true-when-value-present.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.
+/*---
+es6id: 23.3.3.4
+description: >
+  Returns true when value is present in the WeakMap entries list.
+info: >
+  WeakMap.prototype.has ( 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, return
+    true.
+  ...
+---*/
+
+var foo = {};
+var map = new WeakMap();
+
+map.set(foo, 1);
+assert.sameValue(map.has(foo), true);
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
new file mode 100644
index 0000000000..6d6f862f02
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-boolean.js
@@ -0,0 +1,21 @@
+// 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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( value )
+
+  1. Let S be the this value.
+  2. If Type(S) is not Object, throw a TypeError exception.
+
+---*/
+
+assert.throws(TypeError, function() {
+  WeakMap.prototype.has.call(false, {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(false, {});
+});
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.js
new file mode 100644
index 0000000000..8f7863016f
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-null.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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( 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.has.call(null, {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(null, {});
+});
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.js
new file mode 100644
index 0000000000..b6bb5c9830
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-number.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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( 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.has.call(0, {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(0, {});
+});
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.js
new file mode 100644
index 0000000000..5b44cdb08d
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-string.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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( 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.has.call('', {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call('', {});
+});
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
new file mode 100644
index 0000000000..1eb3680cbc
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-symbol.js
@@ -0,0 +1,21 @@
+// 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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( 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.has.call(Symbol(), {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(Symbol(), {});
+});
diff --git a/test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.js
new file mode 100644
index 0000000000..2c8fb4be06
--- /dev/null
+++ b/test/built-ins/WeakMap/prototype/has/this-not-object-throw-undefined.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.4
+description: Throws TypeError if `this` is not Object.
+info: >
+  WeakMap.prototype.has ( 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.has.call(undefined, {});
+});
+
+assert.throws(TypeError, function() {
+  var map = new WeakMap();
+  map.has.call(undefined, {});
+});
-- 
GitLab