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

Unified Diff: runtime/vm/debugger_api_impl_test.cc

Issue 396993008: Debugger test to ensure break on exception works (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger_api_impl_test.cc
===================================================================
--- runtime/vm/debugger_api_impl_test.cc (revision 38299)
+++ runtime/vm/debugger_api_impl_test.cc (working copy)
@@ -2029,6 +2029,51 @@
}
+static void UnhandledExceptionHandler(Dart_IsolateId isolate_id,
+ Dart_Handle exception_object,
+ Dart_StackTrace trace) {
+ breakpoint_hit_counter++;
+}
+
+
+// Check that the debugger is not called when an exception is
+// caught by Dart code.
+TEST_CASE(Debug_BreakOnUnhandledException) {
+ const char* kScriptChars =
+ "void main() { \n"
+ " try { \n"
+ " throw 'broccoli'; \n"
+ " } catch (e) { \n"
+ " return 'carrots'; \n"
+ " } \n"
+ " return 'zucchini'; \n"
+ "} \n";
+
+ LoadScript(kScriptChars);
+ Dart_FinalizeLoading();
+ Dart_SetExceptionThrownHandler(&UnhandledExceptionHandler);
+ breakpoint_hit_counter = 0;
+
+ // Check that the debugger is not called since the exception
+ // is handled.
+ Dart_SetExceptionPauseInfo(kPauseOnUnhandledExceptions);
+ Dart_Handle res = Invoke("main");
+ EXPECT_VALID(res);
+ EXPECT(Dart_IsString(res));
+ EXPECT_STREQ("carrots", ToCString(res));
+ EXPECT_EQ(0, breakpoint_hit_counter);
+
+ // Check that the debugger is called when "break on all
+ // exceptions" is turned on.
+ Dart_SetExceptionPauseInfo(kPauseOnAllExceptions);
+ Dart_Handle res2 = Invoke("main");
+ EXPECT_VALID(res2);
+ EXPECT(Dart_IsString(res2));
+ EXPECT_STREQ("carrots", ToCString(res2));
+ EXPECT_EQ(1, breakpoint_hit_counter);
+}
+
+
TEST_CASE(Debug_GetClosureInfo) {
const char* kScriptChars =
"void foo() { return 43; } \n"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698