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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 11413101: Added support for isolate unhandled exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated code review feedback Created 8 years, 1 month 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index ecc1df1ecd978bb81f3f82ded36f1f1e21b030ce..a4075e46ca95722bfb28fbba3f86dcc650147aee 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -6250,11 +6250,28 @@ static bool RunLoopTestCallback(const char* script_name,
}
+// The error string from the last unhandled exception. This value is only
+// valid until the next Dart_ExitScope().
+static char* last_exception = NULL;
+
+
+static void RunLoopUnhandledExceptionCallback(Dart_Handle exception) {
+ Dart_Handle error_string = Dart_ToString(exception);
+ EXPECT_VALID(error_string);
+ const char* error_text;
+ Dart_Handle result = Dart_StringToCString(error_string, &error_text);
+ // Duplicate the string since error text is freed when callback is finished.
+ last_exception = strdup(error_text);
+ EXPECT_VALID(result);
+}
+
+
// Common code for RunLoop_Success/RunLoop_Failure.
static void RunLoopTest(bool throw_exception_child,
bool throw_exception_parent) {
Dart_IsolateCreateCallback saved = Isolate::CreateCallback();
Isolate::SetCreateCallback(RunLoopTestCallback);
+ Isolate::SetUnhandledExceptionCallback(RunLoopUnhandledExceptionCallback);
RunLoopTestCallback(NULL, NULL, NULL, NULL);
Dart_EnterScope();
@@ -6267,11 +6284,23 @@ static void RunLoopTest(bool throw_exception_child,
args[1] = (throw_exception_parent ? Dart_True() : Dart_False());
result = Dart_Invoke(lib, NewString("main"), 2, args);
EXPECT_VALID(result);
- result = Dart_RunLoop();
- if (throw_exception_parent) {
- EXPECT_ERROR(result, "Exception: MakeParentExit");
+ if (throw_exception_child) {
+ EXPECT_NOTNULL(last_exception);
+ EXPECT_STREQ("UnhandledException", last_exception);
} else {
- EXPECT_VALID(result);
+ result = Dart_RunLoop();
+ if (throw_exception_parent) {
+ EXPECT_ERROR(result, "Exception: MakeParentExit");
+ EXPECT_NOTNULL(last_exception);
+ EXPECT_STREQ("UnhandledException", last_exception);
+ } else {
+ EXPECT_VALID(result);
+ EXPECT(last_exception == NULL);
+ }
+ }
+ if (last_exception != NULL) {
+ free(last_exception);
+ last_exception = NULL;
}
Dart_ExitScope();
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698