| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 assertEquals("Object", %_ClassOf(WeakMap.prototype)) | 281 assertEquals("Object", %_ClassOf(WeakMap.prototype)) |
| 282 | 282 |
| 283 | 283 |
| 284 // Test name of constructor. | 284 // Test name of constructor. |
| 285 assertEquals("Set", Set.name); | 285 assertEquals("Set", Set.name); |
| 286 assertEquals("Map", Map.name); | 286 assertEquals("Map", Map.name); |
| 287 assertEquals("WeakMap", WeakMap.name); | 287 assertEquals("WeakMap", WeakMap.name); |
| 288 assertEquals("WeakSet", WeakSet.name); | 288 assertEquals("WeakSet", WeakSet.name); |
| 289 | 289 |
| 290 | 290 |
| 291 // Test prototype property of Set, Map, WeakMap and WeakSet. |
| 292 function TestPrototype(C) { |
| 293 assertTrue(C.prototype instanceof Object); |
| 294 assertEquals({ |
| 295 value: {}, |
| 296 writable: true, // TODO(2793): This should be non-writable. |
| 297 enumerable: false, |
| 298 configurable: false |
| 299 }, Object.getOwnPropertyDescriptor(C, "prototype")); |
| 300 } |
| 301 TestPrototype(Set); |
| 302 TestPrototype(Map); |
| 303 TestPrototype(WeakMap); |
| 304 TestPrototype(WeakSet); |
| 305 |
| 306 |
| 291 // Test constructor property of the Set, Map, WeakMap and WeakSet prototype. | 307 // Test constructor property of the Set, Map, WeakMap and WeakSet prototype. |
| 292 function TestConstructor(C) { | 308 function TestConstructor(C) { |
| 293 assertFalse(C === Object.prototype.constructor); | 309 assertFalse(C === Object.prototype.constructor); |
| 294 assertSame(C, C.prototype.constructor); | 310 assertSame(C, C.prototype.constructor); |
| 295 assertSame(C, C().__proto__.constructor); | 311 assertSame(C, C().__proto__.constructor); |
| 296 assertSame(C, (new C).__proto__.constructor); | 312 assertSame(C, (new C).__proto__.constructor); |
| 297 } | 313 } |
| 298 TestConstructor(Set); | 314 TestConstructor(Set); |
| 299 TestConstructor(Map); | 315 TestConstructor(Map); |
| 300 TestConstructor(WeakMap); | 316 TestConstructor(WeakMap); |
| 301 TestConstructor(WeakSet); | 317 TestConstructor(WeakSet); |
| 302 | 318 |
| 303 | 319 |
| 320 // Test the Set, Map, WeakMap and WeakSet global properties themselves. |
| 304 function TestDescriptor(global, C) { | 321 function TestDescriptor(global, C) { |
| 305 assertEquals({ | 322 assertEquals({ |
| 306 value: C, | 323 value: C, |
| 307 writable: true, | 324 writable: true, |
| 308 enumerable: false, | 325 enumerable: false, |
| 309 configurable: true | 326 configurable: true |
| 310 }, Object.getOwnPropertyDescriptor(global, C.name)); | 327 }, Object.getOwnPropertyDescriptor(global, C.name)); |
| 311 } | 328 } |
| 312 TestDescriptor(this, Set); | 329 TestDescriptor(this, Set); |
| 313 TestDescriptor(this, Map); | 330 TestDescriptor(this, Map); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 478 |
| 462 // Test WeakSet clear | 479 // Test WeakSet clear |
| 463 (function() { | 480 (function() { |
| 464 var k = new Object(); | 481 var k = new Object(); |
| 465 var w = new WeakSet(); | 482 var w = new WeakSet(); |
| 466 w.add(k); | 483 w.add(k); |
| 467 assertTrue(w.has(k)); | 484 assertTrue(w.has(k)); |
| 468 w.clear(); | 485 w.clear(); |
| 469 assertFalse(w.has(k)); | 486 assertFalse(w.has(k)); |
| 470 })(); | 487 })(); |
| OLD | NEW |