Index: test/mjsunit/harmony/weakmaps.js |
diff --git a/test/mjsunit/harmony/weakmaps.js b/test/mjsunit/harmony/weakmaps.js |
index 52b022bbd88b862e0afec765e323955a9c308f3d..d98db10df3a91d59f9613833fb205f3b81e5618f 100644 |
--- a/test/mjsunit/harmony/weakmaps.js |
+++ b/test/mjsunit/harmony/weakmaps.js |
@@ -32,6 +32,8 @@ |
var m = new WeakMap; |
assertDoesNotThrow(function () { m.get(new Object) }); |
assertDoesNotThrow(function () { m.set(new Object) }); |
+assertDoesNotThrow(function () { m.has(new Object) }); |
+assertDoesNotThrow(function () { m.delete(new Object) }); |
// Test invalid getter and setter calls |
@@ -55,6 +57,27 @@ TestMapping(m, new Object, 'the-value'); |
TestMapping(m, new Object, new Object); |
+// Test expected querying behavior |
+var m = new WeakMap; |
+var key = new Object; |
+TestMapping(m, key, 'to-be-present'); |
+assertTrue(m.has(key)); |
+assertFalse(m.has(new Object)); |
+TestMapping(m, key, undefined); |
+assertFalse(m.has(key)); |
+assertFalse(m.has(new Object)); |
+ |
+ |
+// Test expected deletion behavior |
+var m = new WeakMap; |
+var key = new Object; |
+TestMapping(m, key, 'to-be-deleted'); |
+assertTrue(m.delete(key)); |
+assertFalse(m.delete(key)); |
+assertFalse(m.delete(new Object)); |
+assertSame(m.get(key), undefined); |
+ |
+ |
// Test GC of map with entry |
var m = new WeakMap; |
var key = new Object; |
@@ -112,6 +135,8 @@ var m = new WeakMap; |
assertTrue(m instanceof WeakMap); |
assertTrue(WeakMap.prototype.set instanceof Function) |
assertTrue(WeakMap.prototype.get instanceof Function) |
+assertTrue(WeakMap.prototype.has instanceof Function) |
+assertTrue(WeakMap.prototype.delete instanceof Function) |
// Stress Test |