Debugger test to ensure break on exception works

Tests that the debugger is only called on exceptions when the exception is
unhandled or when it wants to be notified on all exceptions.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//396993008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38316 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
hausner@google.com 2014-07-16 22:30:33 +00:00
parent a9db9d480c
commit d6664499a9

View file

@ -2029,6 +2029,51 @@ TEST_CASE(Debug_EvaluateInActivationOfEvaluate) {
}
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"