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

Unified Diff: test/mjsunit/debug-script-breakpoints-closure.js

Issue 10543141: Enable lazy compilation for non-trivial outer contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 years, 6 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
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/debug-script-breakpoints-nested.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-script-breakpoints-closure.js
diff --git a/test/mjsunit/debug-set-script-source.js b/test/mjsunit/debug-script-breakpoints-closure.js
similarity index 67%
copy from test/mjsunit/debug-set-script-source.js
copy to test/mjsunit/debug-script-breakpoints-closure.js
index 34ae8488a4de608543c543555e11236e1c65726e..e2bb58863fe7bdec9485f2ddcba60f7a840b4573 100644
--- a/test/mjsunit/debug-set-script-source.js
+++ b/test/mjsunit/debug-script-breakpoints-closure.js
@@ -29,36 +29,39 @@
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
-var script_number = 0;
-var script_names = [];
-var exception = null;
+// Simple debug event handler which just counts the number of break points hit.
+var break_point_hit_count = 0;
function listener(event, exec_state, event_data, data) {
- if (event == Debug.DebugEvent.BeforeCompile) {
- event_data.script().setSource(event_data.script().source() +
- " //@ sourceURL=proper_location_" + (++script_number));
- } else if (event == Debug.DebugEvent.AfterCompile) {
- try {
- event_data.script().setSource("a=1 //@ sourceURL=wrong_location");
- } catch(e) {
- exception = e;
- }
- script_names.push(event_data.script().name());
+ if (event == Debug.DebugEvent.Break) {
+ break_point_hit_count++;
}
};
-
// Add the debug event listener.
Debug.setListener(listener);
-// Compile different sources.
-eval('a=1');
-eval('(function(){})');
+function makeClosure() {
+ var x;
+ return function() {
+ return x; // Breakpoint line ( #47 )
+ };
+}
+
+// Create closure before break point is set.
+var closure = makeClosure();
-assertEquals(2, script_names.length);
-assertEquals("proper_location_1", script_names[0]);
-assertEquals("proper_location_2", script_names[1]);
+// The debugger triggers re-compilation.
+assertEquals(0, Debug.scriptBreakPoints().length);
+var scr = Debug.findScript(makeClosure);
+var sbp = Debug.setScriptBreakPointById(scr.id, 47);
+assertEquals(1, Debug.scriptBreakPoints().length);
-assertEquals("illegal access", exception);
+// Ensure the closure actually triggers a break point hit.
+closure();
+assertEquals(1, break_point_hit_count);
-Debug.setListener(null);
+// Remove script break point.
+assertEquals(1, Debug.scriptBreakPoints().length);
+Debug.clearBreakPoint(sbp);
+assertEquals(0, Debug.scriptBreakPoints().length);
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/debug-script-breakpoints-nested.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698