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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 assertFalse(m.hasOwnProperty('size')); 370 assertFalse(m.hasOwnProperty('size'));
371 for (var i = 0; i < 10; i++) { 371 for (var i = 0; i < 10; i++) {
372 assertEquals(i, m.size); 372 assertEquals(i, m.size);
373 m.set(i, i); 373 m.set(i, i);
374 } 374 }
375 for (var i = 9; i >= 0; i--) { 375 for (var i = 9; i >= 0; i--) {
376 m.delete(i); 376 m.delete(i);
377 assertEquals(i, m.size); 377 assertEquals(i, m.size);
378 } 378 }
379 379
380 // Test clear
381 var a = new Set();
382 s.add(42);
383 assertTrue(s.has(42));
384 s.clear();
385 assertFalse(s.has(42));
386 assertEquals(0, s.size);
387 380
388 var m = new Map(); 381 // Test Set clear
389 m.set(42, true); 382 (function() {
390 assertTrue(m.has(42)); 383 var s = new Set();
391 m.clear(); 384 s.add(42);
392 assertFalse(m.has(42)); 385 assertTrue(s.has(42));
393 assertEquals(0, m.size); 386 assertEquals(1, s.size);
387 s.clear();
388 assertFalse(s.has(42));
389 assertEquals(0, s.size);
390 })();
391
392
393 // Test Map clear
394 (function() {
395 var m = new Map();
396 m.set(42, true);
397 assertTrue(m.has(42));
398 assertEquals(1, m.size);
399 m.clear();
400 assertFalse(m.has(42));
401 assertEquals(0, m.size);
402 })();
403
404
405 // Test WeakMap clear
406 (function() {
407 var k = new Object();
408 var w = new WeakMap();
409 w.set(k, 23);
410 assertTrue(w.has(k));
411 assertEquals(23, w.get(k));
412 w.clear();
413 assertFalse(w.has(k));
414 assertEquals(undefined, w.get(k));
415 })();
OLDNEW
« 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