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

Side by Side Diff: test/mjsunit/harmony/collections.js

Issue 11360089: ES6: Adding support for size to Set and Map (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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/v8natives.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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 } 307 }
308 } 308 }
309 } 309 }
310 TestBogusReceivers(bogusReceiversTestSet); 310 TestBogusReceivers(bogusReceiversTestSet);
311 311
312 312
313 // Stress Test 313 // Stress Test
314 // There is a proposed stress-test available at the es-discuss mailing list 314 // There is a proposed stress-test available at the es-discuss mailing list
315 // which cannot be reasonably automated. Check it out by hand if you like: 315 // which cannot be reasonably automated. Check it out by hand if you like:
316 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html 316 // https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html
317
318
319 // Set and Map size getters
320 var setSizeDescriptor = Object.getOwnPropertyDescriptor(Set.prototype, 'size');
321 assertEquals(undefined, setSizeDescriptor.value);
322 assertEquals(undefined, setSizeDescriptor.set);
323 assertTrue(setSizeDescriptor.get instanceof Function);
324 assertEquals(undefined, setSizeDescriptor.get.prototype);
325 assertFalse(setSizeDescriptor.enumerable);
326 assertTrue(setSizeDescriptor.configurable);
327
328 var s = new Set();
329 assertFalse(s.hasOwnProperty('size'));
330 for (var i = 0; i < 10; i++) {
331 assertEquals(i, s.size);
332 s.add(i);
333 }
334 for (var i = 9; i >= 0; i--) {
335 s.delete(i);
336 assertEquals(i, s.size);
337 }
338
339
340 var mapSizeDescriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size');
341 assertEquals(undefined, mapSizeDescriptor.value);
342 assertEquals(undefined, mapSizeDescriptor.set);
343 assertTrue(mapSizeDescriptor.get instanceof Function);
344 assertEquals(undefined, mapSizeDescriptor.get.prototype);
345 assertFalse(mapSizeDescriptor.enumerable);
346 assertTrue(mapSizeDescriptor.configurable);
347
348 var m = new Map();
349 assertFalse(m.hasOwnProperty('size'));
350 for (var i = 0; i < 10; i++) {
351 assertEquals(i, m.size);
352 m.set(i, i);
353 }
354 for (var i = 9; i >= 0; i--) {
355 m.delete(i);
356 assertEquals(i, m.size);
357 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698