Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: test/mjsunit/es6/collections.js

Issue 936793003: Align GetIterator with ES6 spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/weak-collection.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
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('object', typeof this);
1194 return function() { 1194 return function() {
1195 assertEquals('number', typeof this);
1195 return oneAndTwo.keys(); 1196 return oneAndTwo.keys();
1196 }; 1197 };
1197 }, 1198 },
1198 configurable: true 1199 configurable: true
1199 }); 1200 });
1200 1201
1201 var set = new ctor(42); 1202 var set = new ctor(42);
1202 assertSize(2, set); 1203 assertSize(2, set);
1203 assertTrue(set.has(k1)); 1204 assertTrue(set.has(k1));
1204 assertTrue(set.has(k2)); 1205 assertTrue(set.has(k2));
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 })(); 1376 })();
1376 1377
1377 1378
1378 function TestMapConstructorIterableValue(ctor) { 1379 function TestMapConstructorIterableValue(ctor) {
1379 'use strict'; 1380 'use strict';
1380 // Strict mode is required to prevent implicit wrapping in the getter. 1381 // Strict mode is required to prevent implicit wrapping in the getter.
1381 Object.defineProperty(Number.prototype, Symbol.iterator, { 1382 Object.defineProperty(Number.prototype, Symbol.iterator, {
1382 get: function() { 1383 get: function() {
1383 assertEquals('object', typeof this); 1384 assertEquals('object', typeof this);
1384 return function() { 1385 return function() {
1386 assertEquals('number', typeof this);
1385 return oneAndTwo.entries(); 1387 return oneAndTwo.entries();
1386 }; 1388 };
1387 }, 1389 },
1388 configurable: true 1390 configurable: true
1389 }); 1391 });
1390 1392
1391 var map = new ctor(42); 1393 var map = new ctor(42);
1392 assertSize(2, map); 1394 assertSize(2, map);
1393 assertEquals(1, map.get(k1)); 1395 assertEquals(1, map.get(k1));
1394 assertEquals(2, map.get(k2)); 1396 assertEquals(2, map.get(k2));
1395 1397
1396 delete Number.prototype[Symbol.iterator]; 1398 delete Number.prototype[Symbol.iterator];
1397 } 1399 }
1398 TestMapConstructorIterableValue(Map); 1400 TestMapConstructorIterableValue(Map);
1399 TestMapConstructorIterableValue(WeakMap); 1401 TestMapConstructorIterableValue(WeakMap);
1400 1402
1401 function TestCollectionToString(C) { 1403 function TestCollectionToString(C) {
1402 assertEquals("[object " + C.name + "]", 1404 assertEquals("[object " + C.name + "]",
1403 Object.prototype.toString.call(new C())); 1405 Object.prototype.toString.call(new C()));
1404 } 1406 }
1405 TestCollectionToString(Map); 1407 TestCollectionToString(Map);
1406 TestCollectionToString(Set); 1408 TestCollectionToString(Set);
1407 TestCollectionToString(WeakMap); 1409 TestCollectionToString(WeakMap);
1408 TestCollectionToString(WeakSet); 1410 TestCollectionToString(WeakSet);
OLDNEW
« no previous file with comments | « src/weak-collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698