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

Unified Diff: test/mjsunit/es6/mirror-iterators.js

Issue 712083002: Add optional max elements limit for Map/Set mirror iterator preview. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/mirror-collections.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/mirror-iterators.js
diff --git a/test/mjsunit/es6/mirror-iterators.js b/test/mjsunit/es6/mirror-iterators.js
index 02fe7ffde009cd3ac97251bfb99f1ec385abd1c4..cc0b1e45f893139caa73238d48cf63e5463001ea 100644
--- a/test/mjsunit/es6/mirror-iterators.js
+++ b/test/mjsunit/es6/mirror-iterators.js
@@ -5,18 +5,21 @@
// Flags: --expose-debug-as debug
// Test the mirror object for collection iterators.
-function testIteratorMirror(iter, offset, expected) {
+function testIteratorMirror(iter, offset, expected, opt_limit) {
while (offset-- > 0) iter.next();
var mirror = debug.MakeMirror(iter);
assertTrue(mirror.isIterator());
- var preview = mirror.preview();
+ var preview = mirror.preview(opt_limit);
assertArrayEquals(expected, preview);
// Check that iterator has not changed after taking preview.
var values = [];
- for (var i of iter) values.push(i);
+ for (var i of iter) {
+ if (opt_limit && values.length >= opt_limit) break;
+ values.push(i);
+ }
assertArrayEquals(expected, values);
}
@@ -39,6 +42,11 @@ testIteratorMirror(map.keys(), 2, []);
testIteratorMirror(map.values(), 2, []);
testIteratorMirror(map.entries(), 2, []);
+// Test with maximum limit.
+testIteratorMirror(map.keys(), 0, [41], 1);
+testIteratorMirror(map.values(), 0, [42], 1);
+testIteratorMirror(map.entries(), 0, [[41, 42]], 1);
+
var set = new Set();
set.add(41);
set.add(42);
@@ -60,3 +68,8 @@ testIteratorMirror(set.entries(), 3, [[o2, o2]]);
testIteratorMirror(set.keys(), 5, []);
testIteratorMirror(set.values(), 5, []);
testIteratorMirror(set.entries(), 5, []);
+
+// Test with maximum limit.
+testIteratorMirror(set.keys(), 1, [42, o1], 2);
+testIteratorMirror(set.values(), 1, [42, o1], 2);
+testIteratorMirror(set.entries(), 1, [[42, 42], [o1, o1]], 2);
« no previous file with comments | « test/mjsunit/es6/mirror-collections.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698