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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 new WeakSet([1]); | 1183 new WeakSet([1]); |
1184 }, TypeError); | 1184 }, TypeError); |
1185 })(); | 1185 })(); |
1186 | 1186 |
1187 | 1187 |
1188 function TestSetConstructorIterableValue(ctor) { | 1188 function TestSetConstructorIterableValue(ctor) { |
1189 'use strict'; | 1189 'use strict'; |
1190 // Strict mode is required to prevent implicit wrapping in the getter. | 1190 // Strict mode is required to prevent implicit wrapping in the getter. |
1191 Object.defineProperty(Number.prototype, Symbol.iterator, { | 1191 Object.defineProperty(Number.prototype, Symbol.iterator, { |
1192 get: function() { | 1192 get: function() { |
1193 assertEquals('object', typeof this); | 1193 assertEquals('number', typeof this); |
1194 return function() { | 1194 return function() { |
1195 assertEquals('number', typeof this); | 1195 assertEquals('number', typeof this); |
1196 return oneAndTwo.keys(); | 1196 return oneAndTwo.keys(); |
1197 }; | 1197 }; |
1198 }, | 1198 }, |
1199 configurable: true | 1199 configurable: true |
1200 }); | 1200 }); |
1201 | 1201 |
1202 var set = new ctor(42); | 1202 var set = new ctor(42); |
1203 assertSize(2, set); | 1203 assertSize(2, set); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 new WeakMap([[1, 2]]) | 1374 new WeakMap([[1, 2]]) |
1375 }, TypeError); | 1375 }, TypeError); |
1376 })(); | 1376 })(); |
1377 | 1377 |
1378 | 1378 |
1379 function TestMapConstructorIterableValue(ctor) { | 1379 function TestMapConstructorIterableValue(ctor) { |
1380 'use strict'; | 1380 'use strict'; |
1381 // Strict mode is required to prevent implicit wrapping in the getter. | 1381 // Strict mode is required to prevent implicit wrapping in the getter. |
1382 Object.defineProperty(Number.prototype, Symbol.iterator, { | 1382 Object.defineProperty(Number.prototype, Symbol.iterator, { |
1383 get: function() { | 1383 get: function() { |
1384 assertEquals('object', typeof this); | 1384 assertEquals('number', typeof this); |
1385 return function() { | 1385 return function() { |
1386 assertEquals('number', typeof this); | 1386 assertEquals('number', typeof this); |
1387 return oneAndTwo.entries(); | 1387 return oneAndTwo.entries(); |
1388 }; | 1388 }; |
1389 }, | 1389 }, |
1390 configurable: true | 1390 configurable: true |
1391 }); | 1391 }); |
1392 | 1392 |
1393 var map = new ctor(42); | 1393 var map = new ctor(42); |
1394 assertSize(2, map); | 1394 assertSize(2, map); |
1395 assertEquals(1, map.get(k1)); | 1395 assertEquals(1, map.get(k1)); |
1396 assertEquals(2, map.get(k2)); | 1396 assertEquals(2, map.get(k2)); |
1397 | 1397 |
1398 delete Number.prototype[Symbol.iterator]; | 1398 delete Number.prototype[Symbol.iterator]; |
1399 } | 1399 } |
1400 TestMapConstructorIterableValue(Map); | 1400 TestMapConstructorIterableValue(Map); |
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); |
OLD | NEW |