Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
| 6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "include/dart_tools_api.h" | 9 #include "include/dart_tools_api.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 | 441 |
| 442 EXPECT_STREQ("", Dart_GetError(not_error)); | 442 EXPECT_STREQ("", Dart_GetError(not_error)); |
| 443 EXPECT_STREQ("ApiError", Dart_GetError(api_error)); | 443 EXPECT_STREQ("ApiError", Dart_GetError(api_error)); |
| 444 EXPECT_SUBSTRING("Unhandled exception:\nExceptionError", | 444 EXPECT_SUBSTRING("Unhandled exception:\nExceptionError", |
| 445 Dart_GetError(exception_error)); | 445 Dart_GetError(exception_error)); |
| 446 EXPECT_STREQ("CompileError", Dart_GetError(compile_error)); | 446 EXPECT_STREQ("CompileError", Dart_GetError(compile_error)); |
| 447 EXPECT_STREQ("FatalError", Dart_GetError(fatal_error)); | 447 EXPECT_STREQ("FatalError", Dart_GetError(fatal_error)); |
| 448 } | 448 } |
| 449 | 449 |
| 450 | 450 |
| 451 TEST_CASE(UnhandleExceptionError) { | |
| 452 Isolate* isolate = Isolate::Current(); | |
| 453 | |
| 454 // Test with an API Error. | |
| 455 Dart_Handle api_error = Api::NewHandle( | |
| 456 isolate, | |
| 457 ApiError::New(String::Handle(String::New("Api Error Exception Test.")))); | |
| 458 Dart_Handle exception_error = Dart_NewUnhandledExceptionError(api_error); | |
| 459 EXPECT(!Dart_IsApiError(exception_error)); | |
| 460 EXPECT(Dart_IsUnhandledExceptionError(exception_error)); | |
| 461 | |
|
rmacnak
2015/06/19 23:26:10
EXPECT(Dart_IsString(Dart_ErrorGetException(except
siva
2015/06/19 23:43:44
Done.
| |
| 462 // Test with a Compilation Error. | |
| 463 const String& compile_message = | |
| 464 String::Handle(String::New("CompileError Exception Test.")); | |
| 465 Dart_Handle compile_error = | |
| 466 Api::NewHandle(isolate, LanguageError::New(compile_message)); | |
| 467 exception_error = Dart_NewUnhandledExceptionError(compile_error); | |
| 468 EXPECT(!Dart_IsApiError(exception_error)); | |
| 469 EXPECT(Dart_IsUnhandledExceptionError(exception_error)); | |
| 470 | |
|
rmacnak
2015/06/19 23:26:10
Ditto
siva
2015/06/19 23:43:44
Done.
| |
| 471 // Test with a Fatal Error. | |
| 472 const String& fatal_message = | |
| 473 String::Handle(String::New("FatalError Exception Test.")); | |
| 474 Dart_Handle fatal_error = | |
| 475 Api::NewHandle(isolate, UnwindError::New(fatal_message)); | |
| 476 exception_error = Dart_NewUnhandledExceptionError(fatal_error); | |
| 477 EXPECT(Dart_IsError(exception_error)); | |
| 478 EXPECT(!Dart_IsUnhandledExceptionError(exception_error)); | |
| 479 | |
| 480 // Test with a Regular object. | |
| 481 Dart_Handle obj = Api::NewHandle( | |
| 482 isolate, | |
| 483 String::New("Regular String Exception Test.")); | |
| 484 exception_error = Dart_NewUnhandledExceptionError(obj); | |
| 485 EXPECT(!Dart_IsApiError(exception_error)); | |
| 486 EXPECT(Dart_IsUnhandledExceptionError(exception_error)); | |
|
rmacnak
2015/06/19 23:26:10
Ditto
siva
2015/06/19 23:43:44
Done.
| |
| 487 } | |
| 488 | |
| 489 | |
| 451 void PropagateErrorNative(Dart_NativeArguments args) { | 490 void PropagateErrorNative(Dart_NativeArguments args) { |
| 452 Dart_EnterScope(); | 491 Dart_EnterScope(); |
| 453 Dart_Handle closure = Dart_GetNativeArgument(args, 0); | 492 Dart_Handle closure = Dart_GetNativeArgument(args, 0); |
| 454 EXPECT(Dart_IsClosure(closure)); | 493 EXPECT(Dart_IsClosure(closure)); |
| 455 Dart_Handle result = Dart_InvokeClosure(closure, 0, NULL); | 494 Dart_Handle result = Dart_InvokeClosure(closure, 0, NULL); |
| 456 EXPECT(Dart_IsError(result)); | 495 EXPECT(Dart_IsError(result)); |
| 457 result = Dart_PropagateError(result); | 496 result = Dart_PropagateError(result); |
| 458 EXPECT_VALID(result); // We do not expect to reach here. | 497 EXPECT_VALID(result); // We do not expect to reach here. |
| 459 UNREACHABLE(); | 498 UNREACHABLE(); |
| 460 } | 499 } |
| (...skipping 8758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9219 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); | 9258 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); |
| 9220 | 9259 |
| 9221 // Check that it is in the output. | 9260 // Check that it is in the output. |
| 9222 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9261 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); |
| 9223 JSONStream js; | 9262 JSONStream js; |
| 9224 recorder->PrintJSON(&js); | 9263 recorder->PrintJSON(&js); |
| 9225 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); | 9264 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); |
| 9226 } | 9265 } |
| 9227 | 9266 |
| 9228 } // namespace dart | 9267 } // namespace dart |
| OLD | NEW |