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

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

Issue 693813002: Add debug mirror support for ES6 Map/Set iterators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added v8::Value::IsMapIterator and v8::Value::IsSetIterator Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« src/factory.cc ('K') | « src/runtime/runtime-collections.cc ('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
new file mode 100644
index 0000000000000000000000000000000000000000..1f7608e31438885e39769866657ae5934bc66b33
--- /dev/null
+++ b/test/mjsunit/es6/mirror-iterators.js
@@ -0,0 +1,38 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug
+// Test the mirror object for collection iterators.
+
+function testIteratorMirror(iter, expected) {
+ var mirror = debug.MakeMirror(iter);
+ assertTrue(mirror.isIterator());
+
+ var preview = mirror.preview();
+ assertArrayEquals(expected, preview);
+
+ // Check that iterator has not changed after taking preview.
+ var values = [];
+ for (var i of iter) values.push(i);
+ assertArrayEquals(expected, values);
+}
+
+var o1 = { foo: 1 };
+var o2 = { foo: 2 };
+
+var map = new Map();
+map.set(41, 42);
+map.set(o1, o2);
+testIteratorMirror(map.keys(), [41, o1]);
+testIteratorMirror(map.values(), [42, o2]);
+testIteratorMirror(map.entries(), [[41, 42], [o1, o2]]);
+
+var set = new Set();
+set.add(41);
+set.add(42);
+set.add(o1);
+set.add(o2);
+testIteratorMirror(set.keys(), [41, 42, o1, o2]);
+testIteratorMirror(set.values(), [41, 42, o1, o2]);
+testIteratorMirror(set.entries(), [[41, 41], [42, 42], [o1, o1], [o2, o2]]);
arv (Not doing code reviews) 2014/10/31 10:20:18 I think it would be good to have a test that crea
aandrey 2014/10/31 10:43:22 Done.
« src/factory.cc ('K') | « src/runtime/runtime-collections.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698