OLD | NEW |
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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 var m = new Map(); | 348 var m = new Map(); |
349 assertFalse(m.hasOwnProperty('size')); | 349 assertFalse(m.hasOwnProperty('size')); |
350 for (var i = 0; i < 10; i++) { | 350 for (var i = 0; i < 10; i++) { |
351 assertEquals(i, m.size); | 351 assertEquals(i, m.size); |
352 m.set(i, i); | 352 m.set(i, i); |
353 } | 353 } |
354 for (var i = 9; i >= 0; i--) { | 354 for (var i = 9; i >= 0; i--) { |
355 m.delete(i); | 355 m.delete(i); |
356 assertEquals(i, m.size); | 356 assertEquals(i, m.size); |
357 } | 357 } |
| 358 |
| 359 // Test clear |
| 360 var a = new Set(); |
| 361 s.add(42); |
| 362 assertTrue(s.has(42)); |
| 363 s.clear(); |
| 364 assertFalse(s.has(42)); |
| 365 assertEquals(0, s.size); |
| 366 |
| 367 var m = new Map(); |
| 368 m.set(42, true); |
| 369 assertTrue(m.has(42)); |
| 370 m.clear(); |
| 371 assertFalse(m.has(42)); |
| 372 assertEquals(0, m.size); |
OLD | NEW |