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

Unified Diff: test/mjsunit/debug-liveedit-stepin.js

Issue 1493733002: [debugger] fix liveedit in combination with step in. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « src/compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-liveedit-stepin.js
diff --git a/test/mjsunit/debug-liveedit-stepin.js b/test/mjsunit/debug-liveedit-stepin.js
new file mode 100644
index 0000000000000000000000000000000000000000..078b06ddb8069af43a19db157f04da6287e474a8
--- /dev/null
+++ b/test/mjsunit/debug-liveedit-stepin.js
@@ -0,0 +1,81 @@
+// Copyright 2015 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
+
+function BestEditor() {
+ var best_editor = "Emacs";
+ return best_editor;
+}
+
+var exception = null;
+var results = [];
+var log = []
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ var source_line = event_data.sourceLineText();
+ log.push(source_line);
+ if (source_line.indexOf("return") >= 0) {
+ switch (results.length) {
+ case 0:
+ break;
+ case 1:
+ Replace(BestEditor, "Emacs", "Eclipse");
+ break;
+ case 2:
+ Replace(BestEditor, "Eclipse", "Vim");
+ break;
+ default:
+ assertUnreachable();
+ }
+ }
+ exec_state.prepareStep(Debug.StepAction.StepIn, 1);
+ } catch (e) {
+ exception = e;
+ }
+};
+
+function Replace(fun, original, patch) {
+ var script = Debug.findScript(fun);
+ if (fun.toString().indexOf(original) < 0) return;
+ var patch_pos = script.source.indexOf(original);
+ var change_log = [];
+ Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script, patch_pos, original.length, patch, change_log);
+}
+
+Debug.setListener(listener);
+
+debugger;
+results.push(BestEditor());
+results.push(BestEditor());
+results.push(BestEditor());
+Debug.setListener(null);
+
+assertNull(exception);
+assertEquals(["Emacs", "Eclipse", "Vim"], results);
+print(JSON.stringify(log, 1));
+assertEquals([
+ "debugger;",
+ "results.push(BestEditor());",
+ " var best_editor = \"Emacs\";",
+ " return best_editor;","}",
+ "results.push(BestEditor());",
+ "results.push(BestEditor());",
+ " var best_editor = \"Emacs\";",
+ " return best_editor;",
+ " var best_editor = \"Eclipse\";",
+ " return best_editor;","}",
+ "results.push(BestEditor());",
+ "results.push(BestEditor());",
+ " var best_editor = \"Eclipse\";",
+ " return best_editor;",
+ " var best_editor = \"Vim\";",
+ " return best_editor;",
+ "}","results.push(BestEditor());",
+ "Debug.setListener(null);"
+], log);
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698