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

Unified Diff: test/mjsunit/es6/debug-stepin-collections-foreach.js

Issue 2480283002: Revert of [debugger] Migrate more debugger tests to inspector (Closed)
Patch Set: Created 4 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/debug-step-into-regexp-subclass.js ('k') | test/mjsunit/es6/debug-stepin-generators.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/debug-stepin-collections-foreach.js
diff --git a/test/mjsunit/es6/debug-stepin-collections-foreach.js b/test/mjsunit/es6/debug-stepin-collections-foreach.js
new file mode 100644
index 0000000000000000000000000000000000000000..5551843cb2580b77002d9a22a5084aaaf5bc8584
--- /dev/null
+++ b/test/mjsunit/es6/debug-stepin-collections-foreach.js
@@ -0,0 +1,100 @@
+// 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
+
+Debug = debug.Debug
+
+var exception = null;
+
+function listener(event, exec_state, event_data, data) {
+ try {
+ if (event == Debug.DebugEvent.Break) {
+ exec_state.prepareStep(Debug.StepAction.StepIn);
+ print(event_data.sourceLineText());
+ assertTrue(
+ event_data.sourceLineText().indexOf(`B${breaks++}`) > 0);
+ }
+ } catch (e) {
+ print(e);
+ quit();
+ exception = e;
+ }
+}
+
+function cb_set(num) {
+ print("element " + num); // B2 B5 B8
+ return true; // B3 B6 B9
+} // B4 B7 B10
+
+function cb_map(key, val) {
+ print("key " + key + ", value " + val); // B2 B5 B8
+ return true; // B3 B6 B9
+} // B4 B7 B10
+
+var s = new Set();
+s.add(1);
+s.add(2);
+s.add(3);
+
+var m = new Map();
+m.set('foo', 1);
+m.set('bar', 2);
+m.set('baz', 3);
+
+var breaks = 0;
+Debug.setListener(listener);
+debugger; // B0
+s.forEach(cb_set); // B1
+Debug.setListener(null); // B11
+assertNull(exception);
+assertEquals(12, breaks);
+
+breaks = 0;
+Debug.setListener(listener);
+debugger; // B0
+m.forEach(cb_map); // B1
+Debug.setListener(null); // B11
+assertNull(exception);
+assertEquals(12, breaks);
+
+// Test two levels of builtin callbacks:
+// Array.forEach calls a callback function, which by itself uses
+// Array.forEach with another callback function.
+
+function cb_set_2(num) {
+ print("element " + num); // B3 B6 B9 B15 B18 B21 B27 B30 B33
+ return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34
+} // B5 B8 B11 B17 B20 B23 B29 B32 B35
+
+function cb_map_2(k, v) {
+ print(`key ${k}, value ${v}`); // B3 B6 B9 B15 B18 B21 B27 B30 B33
+ return true; // B4 B7 B10 B16 B19 B22 B28 B31 B34
+} // B5 B8 B11 B17 B20 B23 B29 B32 B35
+
+function cb_set_foreach(num) {
+ s.forEach(cb_set_2); // B2 B14 B26
+ print("back."); // B12 B24 B36
+} // B13 B25 B37
+
+function cb_map_foreach(key, val) {
+ m.forEach(cb_map_2); // B2 B14 B26
+ print("back."); // B12 B24 B36
+} // B13 B25 B37
+
+breaks = 0;
+Debug.setListener(listener);
+debugger; // B0
+s.forEach(cb_set_foreach); // B1
+Debug.setListener(null); // B38
+assertNull(exception);
+assertEquals(39, breaks);
+
+breaks = 0;
+Debug.setListener(listener);
+debugger; // B0
+m.forEach(cb_map_foreach); // B1
+Debug.setListener(null); // B38
+assertNull(exception);
+assertEquals(39, breaks);
« no previous file with comments | « test/mjsunit/es6/debug-step-into-regexp-subclass.js ('k') | test/mjsunit/es6/debug-stepin-generators.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698