Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1611)

Unified Diff: test/mjsunit/harmony/collections.js

Issue 18352002: Implement WeakMap.prototype.clear function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix minor typo. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/collections.js
diff --git a/test/mjsunit/harmony/collections.js b/test/mjsunit/harmony/collections.js
index d60c59c90712edc3a84b077280d11a8964d12f76..cf18745ae85a30d5f2748838777d156de2799143 100644
--- a/test/mjsunit/harmony/collections.js
+++ b/test/mjsunit/harmony/collections.js
@@ -377,17 +377,39 @@ for (var i = 9; i >= 0; i--) {
assertEquals(i, m.size);
}
-// Test clear
-var a = new Set();
-s.add(42);
-assertTrue(s.has(42));
-s.clear();
-assertFalse(s.has(42));
-assertEquals(0, s.size);
-var m = new Map();
-m.set(42, true);
-assertTrue(m.has(42));
-m.clear();
-assertFalse(m.has(42));
-assertEquals(0, m.size);
+// Test Set clear
+(function() {
+ var s = new Set();
+ s.add(42);
+ assertTrue(s.has(42));
+ assertEquals(1, s.size);
+ s.clear();
+ assertFalse(s.has(42));
+ assertEquals(0, s.size);
+})();
+
+
+// Test Map clear
+(function() {
+ var m = new Map();
+ m.set(42, true);
+ assertTrue(m.has(42));
+ assertEquals(1, m.size);
+ m.clear();
+ assertFalse(m.has(42));
+ assertEquals(0, m.size);
+})();
+
+
+// Test WeakMap clear
+(function() {
+ var k = new Object();
+ var w = new WeakMap();
+ w.set(k, 23);
+ assertTrue(w.has(k));
+ assertEquals(23, w.get(k));
+ w.clear();
+ assertFalse(w.has(k));
+ assertEquals(undefined, w.get(k));
+})();
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698