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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 9316071: Dart_PropagateError, take 2. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_entry.h » ('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
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 3862)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -59,6 +59,68 @@
EXPECT_VALID(Dart_ErrorGetStacktrace(exception));
}
+
+void PropagateErrorNative(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle closure = Dart_GetNativeArgument(args, 0);
+ EXPECT(Dart_IsClosure(closure));
+ Dart_Handle result = Dart_InvokeClosure(closure, 0, NULL);
+ EXPECT(Dart_IsError(result));
+ result = Dart_PropagateError(result);
+ EXPECT_VALID(result); // We do not expect to reach here.
+ UNREACHABLE();
+}
+
+
+static Dart_NativeFunction PropagateError_native_lookup(
+ Dart_Handle name, int argument_count) {
+ return reinterpret_cast<Dart_NativeFunction>(&PropagateErrorNative);
+}
+
+
+TEST_CASE(Dart_PropagateError) {
+ const char* kScriptChars =
+ "class Test {\n"
+ " static void raiseCompileError() {\n"
+ " return badIdent;\n"
+ " }\n"
+ "\n"
+ " static void throwException() {\n"
+ " throw new Exception('myException');\n"
+ " }\n"
+ " static void nativeFunc(closure) native 'Test_nativeFunc';\n"
+ "\n"
+ " static void Func1() {\n"
+ " nativeFunc(() => raiseCompileError());\n"
+ " }\n"
+ "\n"
+ " static void Func2() {\n"
+ " nativeFunc(() => throwException());\n"
+ " }\n"
+ "}\n";
+ Dart_Handle lib = TestCase::LoadTestScript(
+ kScriptChars, &PropagateError_native_lookup);
+ Dart_Handle result;
+
+ result = Dart_InvokeStatic(lib,
+ Dart_NewString("Test"),
+ Dart_NewString("Func1"),
+ 0,
+ NULL);
+ EXPECT(Dart_IsError(result));
+ EXPECT(!Dart_ErrorHasException(result));
+ EXPECT_SUBSTRING("badIdent", Dart_GetError(result));
+
+ result = Dart_InvokeStatic(lib,
+ Dart_NewString("Test"),
+ Dart_NewString("Func2"),
+ 0,
+ NULL);
+ EXPECT(Dart_IsError(result));
+ EXPECT(Dart_ErrorHasException(result));
+ EXPECT_SUBSTRING("myException", Dart_GetError(result));
+}
+
#endif
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698