| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 if (!expected.Equals(actual)) { | 23 if (!expected.Equals(actual)) { |
| 24 OS::Print("expected: '%s' actual: '%s'\n", | 24 OS::Print("expected: '%s' actual: '%s'\n", |
| 25 expected.ToCString(), actual.ToCString()); | 25 expected.ToCString(), actual.ToCString()); |
| 26 FATAL("Unhandled_equals fails.\n"); | 26 FATAL("Unhandled_equals fails.\n"); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 | 30 |
| 31 void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) { | 31 void FUNCTION_NAME(Unhandled_invoke)(Dart_NativeArguments args) { |
| 32 // Invoke the specified entry point. | 32 // Invoke the specified entry point. |
| 33 Dart_Handle result = Dart_InvokeStatic(TestCase::lib(), | 33 Dart_Handle cls = Dart_GetClass(TestCase::lib(), Dart_NewString("Second")); |
| 34 Dart_NewString("Second"), | 34 Dart_Handle result = Dart_Invoke(cls, |
| 35 Dart_NewString("method2"), | 35 Dart_NewString("method2"), |
| 36 0, | 36 0, |
| 37 NULL); | 37 NULL); |
| 38 ASSERT(Dart_IsError(result)); | 38 ASSERT(Dart_IsError(result)); |
| 39 ASSERT(Dart_ErrorHasException(result)); | 39 ASSERT(Dart_ErrorHasException(result)); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 void FUNCTION_NAME(Unhandled_invoke2)(Dart_NativeArguments args) { | 44 void FUNCTION_NAME(Unhandled_invoke2)(Dart_NativeArguments args) { |
| 45 // Invoke the specified entry point. | 45 // Invoke the specified entry point. |
| 46 Dart_Handle result = Dart_InvokeStatic(TestCase::lib(), | 46 Dart_Handle cls = Dart_GetClass(TestCase::lib(), Dart_NewString("Second")); |
| 47 Dart_NewString("Second"), | 47 Dart_Handle result = Dart_Invoke(cls, |
| 48 Dart_NewString("method2"), | 48 Dart_NewString("method2"), |
| 49 0, | 49 0, |
| 50 NULL); | 50 NULL); |
| 51 ASSERT(Dart_IsError(result)); | 51 ASSERT(Dart_IsError(result)); |
| 52 ASSERT(Dart_ErrorHasException(result)); | 52 ASSERT(Dart_ErrorHasException(result)); |
| 53 Dart_Handle exception = Dart_ErrorGetException(result); | 53 Dart_Handle exception = Dart_ErrorGetException(result); |
| 54 ASSERT(!Dart_IsError(exception)); | 54 ASSERT(!Dart_IsError(exception)); |
| 55 Dart_ThrowException(exception); | 55 Dart_ThrowException(exception); |
| 56 UNREACHABLE(); | 56 UNREACHABLE(); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 " }\n" | 112 " }\n" |
| 113 " static int method3(int param) {\n" | 113 " static int method3(int param) {\n" |
| 114 " try {\n" | 114 " try {\n" |
| 115 " UnhandledExceptions.invoke2();\n" | 115 " UnhandledExceptions.invoke2();\n" |
| 116 " } catch (Second e) {\n" | 116 " } catch (Second e) {\n" |
| 117 " return 3;\n" | 117 " return 3;\n" |
| 118 " }\n" | 118 " }\n" |
| 119 " return 2;\n" | 119 " return 2;\n" |
| 120 " }\n" | 120 " }\n" |
| 121 "}\n" | 121 "}\n" |
| 122 "class UnhandledExceptionTest {\n" | 122 "testMain() {\n" |
| 123 " static testMain() {\n" | 123 " UnhandledExceptions.equals(2, Second.method1(1));\n" |
| 124 " UnhandledExceptions.equals(2, Second.method1(1));\n" | 124 " UnhandledExceptions.equals(3, Second.method3(1));\n" |
| 125 " UnhandledExceptions.equals(3, Second.method3(1));\n" | |
| 126 " }\n" | |
| 127 "}"; | 125 "}"; |
| 128 Dart_Handle lib = TestCase::LoadTestScript( | 126 Dart_Handle lib = TestCase::LoadTestScript( |
| 129 kScriptChars, | 127 kScriptChars, |
| 130 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 128 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
| 131 Dart_InvokeStatic(lib, | 129 EXPECT_VALID(Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL)); |
| 132 Dart_NewString("UnhandledExceptionTest"), | |
| 133 Dart_NewString("testMain"), | |
| 134 0, | |
| 135 NULL); | |
| 136 } | 130 } |
| 137 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 131 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 138 | 132 |
| 139 } // namespace dart | 133 } // namespace dart |
| OLD | NEW |