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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 assertFalse(setSizeDescriptor.enumerable); |
| 325 assertTrue(setSizeDescriptor.configurable); |
| 326 |
| 327 var s = new Set(); |
| 328 assertFalse(s.hasOwnProperty('size')); |
| 329 for (var i = 0; i < 10; i++) { |
| 330 assertEquals(i, s.size); |
| 331 s.add(i); |
| 332 } |
| 333 for (var i = 9; i >= 0; i--) { |
| 334 s.delete(i); |
| 335 assertEquals(i, s.size); |
| 336 } |
| 337 |
| 338 |
| 339 var mapSizeDescriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size'); |
| 340 assertEquals(undefined, mapSizeDescriptor.value); |
| 341 assertEquals(undefined, mapSizeDescriptor.set); |
| 342 assertTrue(mapSizeDescriptor.get instanceof Function); |
| 343 assertFalse(mapSizeDescriptor.enumerable); |
| 344 assertTrue(mapSizeDescriptor.configurable); |
| 345 |
| 346 var m = new Map(); |
| 347 assertFalse(m.hasOwnProperty('size')); |
| 348 for (var i = 0; i < 10; i++) { |
| 349 assertEquals(i, m.size); |
| 350 m.set(i, i); |
| 351 } |
| 352 for (var i = 9; i >= 0; i--) { |
| 353 m.delete(i); |
| 354 assertEquals(i, m.size); |
| 355 } |
OLD | NEW |