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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions); 2022 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions);
2023 breakpoint_hit_counter = 0; 2023 breakpoint_hit_counter = 0;
2024 2024
2025 Dart_Handle result = Dart_EvaluateExpr(script_lib, NewString( 2025 Dart_Handle result = Dart_EvaluateExpr(script_lib, NewString(
2026 "() { var p = new Point(3, 4); throw p; } ())")); 2026 "() { var p = new Point(3, 4); throw p; } ())"));
2027 EXPECT(Dart_IsError(result)); 2027 EXPECT(Dart_IsError(result));
2028 EXPECT_EQ(1, breakpoint_hit_counter); 2028 EXPECT_EQ(1, breakpoint_hit_counter);
2029 } 2029 }
2030 2030
2031 2031
2032 static void UnhandledExceptionHandler(Dart_IsolateId isolate_id,
2033 Dart_Handle exception_object,
2034 Dart_StackTrace trace) {
2035 breakpoint_hit_counter++;
2036 }
2037
2038
2039 // Check that the debugger is not called when an exception is
2040 // caught by Dart code.
2041 TEST_CASE(Debug_BreakOnUnhandledException) {
2042 const char* kScriptChars =
2043 "void main() { \n"
2044 " try { \n"
2045 " throw 'broccoli'; \n"
2046 " } catch (e) { \n"
2047 " return 'carrots'; \n"
2048 " } \n"
2049 " return 'zucchini'; \n"
2050 "} \n";
2051
2052 LoadScript(kScriptChars);
2053 Dart_FinalizeLoading();
2054 Dart_SetExceptionThrownHandler(&UnhandledExceptionHandler);
2055 breakpoint_hit_counter = 0;
2056
2057 // Check that the debugger is not called since the exception
2058 // is handled.
2059 Dart_SetExceptionPauseInfo(kPauseOnUnhandledExceptions);
2060 Dart_Handle res = Invoke("main");
2061 EXPECT_VALID(res);
2062 EXPECT(Dart_IsString(res));
2063 EXPECT_STREQ("carrots", ToCString(res));
2064 EXPECT_EQ(0, breakpoint_hit_counter);
2065
2066 // Check that the debugger is called when "break on all
2067 // exceptions" is turned on.
2068 Dart_SetExceptionPauseInfo(kPauseOnAllExceptions);
2069 Dart_Handle res2 = Invoke("main");
2070 EXPECT_VALID(res2);
2071 EXPECT(Dart_IsString(res2));
2072 EXPECT_STREQ("carrots", ToCString(res2));
2073 EXPECT_EQ(1, breakpoint_hit_counter);
2074 }
2075
2076
2032 TEST_CASE(Debug_GetClosureInfo) { 2077 TEST_CASE(Debug_GetClosureInfo) {
2033 const char* kScriptChars = 2078 const char* kScriptChars =
2034 "void foo() { return 43; } \n" 2079 "void foo() { return 43; } \n"
2035 " \n" 2080 " \n"
2036 "main() { \n" 2081 "main() { \n"
2037 " return foo; \n" 2082 " return foo; \n"
2038 "} \n"; 2083 "} \n";
2039 2084
2040 LoadScript(kScriptChars); 2085 LoadScript(kScriptChars);
2041 Dart_Handle clo = Invoke("main"); 2086 Dart_Handle clo = Invoke("main");
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13," 2305 " null, 3, 7, 1, 8, 6, 9, 10, 10, 11, 11, 13,"
2261 " null, 4, 13, 3, 14, 10," 2306 " null, 4, 13, 3, 14, 10,"
2262 " null, 5, 17, 5, 18, 9, 19, 12," 2307 " null, 5, 17, 5, 18, 9, 19, 12,"
2263 " null, 6, 21, 1," 2308 " null, 6, 21, 1,"
2264 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8," 2309 " null, 8, 24, 1, 25, 5, 26, 6, 27, 8,"
2265 " null, 9, 29, 1]", 2310 " null, 9, 29, 1]",
2266 tokens_cstr); 2311 tokens_cstr);
2267 } 2312 }
2268 2313
2269 } // namespace dart 2314 } // namespace dart
OLDNEW
« 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