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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 TestMapConstructorIterableValue(WeakMap); | 1401 TestMapConstructorIterableValue(WeakMap); |
1402 | 1402 |
1403 function TestCollectionToString(C) { | 1403 function TestCollectionToString(C) { |
1404 assertEquals("[object " + C.name + "]", | 1404 assertEquals("[object " + C.name + "]", |
1405 Object.prototype.toString.call(new C())); | 1405 Object.prototype.toString.call(new C())); |
1406 } | 1406 } |
1407 TestCollectionToString(Map); | 1407 TestCollectionToString(Map); |
1408 TestCollectionToString(Set); | 1408 TestCollectionToString(Set); |
1409 TestCollectionToString(WeakMap); | 1409 TestCollectionToString(WeakMap); |
1410 TestCollectionToString(WeakSet); | 1410 TestCollectionToString(WeakSet); |
| 1411 |
| 1412 |
| 1413 function TestConstructorOrderOfAdderIterator(ctor, adderName) { |
| 1414 var iterable = new Map(); |
| 1415 iterable.set({}, {}); |
| 1416 iterable.set({}, {}); |
| 1417 var iterableFunction = iterable[Symbol.iterator]; |
| 1418 Object.defineProperty(iterable, Symbol.iterator, { |
| 1419 get: function() { |
| 1420 log += 'iterator'; |
| 1421 return iterableFunction; |
| 1422 } |
| 1423 }); |
| 1424 |
| 1425 var log = ''; |
| 1426 var adderFunction = ctor.prototype[adderName]; |
| 1427 |
| 1428 Object.defineProperty(ctor.prototype, adderName, { |
| 1429 get: function() { |
| 1430 log += adderName; |
| 1431 return adderFunction; |
| 1432 } |
| 1433 }); |
| 1434 |
| 1435 new ctor(iterable); |
| 1436 assertEquals(adderName + 'iterator', log); |
| 1437 |
| 1438 Object.defineProperty(ctor.prototype, adderName, { |
| 1439 value: adderFunction |
| 1440 }); |
| 1441 } |
| 1442 TestConstructorOrderOfAdderIterator(Map, 'set'); |
| 1443 TestConstructorOrderOfAdderIterator(Set, 'add'); |
| 1444 TestConstructorOrderOfAdderIterator(WeakMap, 'set'); |
| 1445 TestConstructorOrderOfAdderIterator(WeakSet, 'add'); |
OLD | NEW |