| 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 "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 static Dart_NativeFunction PropagateError_native_lookup( | 129 static Dart_NativeFunction PropagateError_native_lookup( |
| 130 Dart_Handle name, int argument_count) { | 130 Dart_Handle name, int argument_count) { |
| 131 return reinterpret_cast<Dart_NativeFunction>(&PropagateErrorNative); | 131 return reinterpret_cast<Dart_NativeFunction>(&PropagateErrorNative); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 TEST_CASE(Dart_PropagateError) { | 135 TEST_CASE(Dart_PropagateError) { |
| 136 const char* kScriptChars = | 136 const char* kScriptChars = |
| 137 "raiseCompileError() {\n" | 137 "raiseCompileError() {\n" |
| 138 " return badIdent;\n" | 138 " return missing_semicolon\n" |
| 139 "}\n" | 139 "}\n" |
| 140 "\n" | 140 "\n" |
| 141 "void throwException() {\n" | 141 "void throwException() {\n" |
| 142 " throw new Exception('myException');\n" | 142 " throw new Exception('myException');\n" |
| 143 "}\n" | 143 "}\n" |
| 144 "\n" | 144 "\n" |
| 145 "void nativeFunc(closure) native 'Test_nativeFunc';\n" | 145 "void nativeFunc(closure) native 'Test_nativeFunc';\n" |
| 146 "\n" | 146 "\n" |
| 147 "void Func1() {\n" | 147 "void Func1() {\n" |
| 148 " nativeFunc(() => raiseCompileError());\n" | 148 " nativeFunc(() => raiseCompileError());\n" |
| 149 "}\n" | 149 "}\n" |
| 150 "\n" | 150 "\n" |
| 151 "void Func2() {\n" | 151 "void Func2() {\n" |
| 152 " nativeFunc(() => throwException());\n" | 152 " nativeFunc(() => throwException());\n" |
| 153 "}\n"; | 153 "}\n"; |
| 154 Dart_Handle lib = TestCase::LoadTestScript( | 154 Dart_Handle lib = TestCase::LoadTestScript( |
| 155 kScriptChars, &PropagateError_native_lookup); | 155 kScriptChars, &PropagateError_native_lookup); |
| 156 Dart_Handle result; | 156 Dart_Handle result; |
| 157 | 157 |
| 158 result = Dart_Invoke(lib, Dart_NewString("Func1"), 0, NULL); | 158 result = Dart_Invoke(lib, Dart_NewString("Func1"), 0, NULL); |
| 159 EXPECT(Dart_IsError(result)); | 159 EXPECT(Dart_IsError(result)); |
| 160 EXPECT(!Dart_ErrorHasException(result)); | 160 EXPECT(!Dart_ErrorHasException(result)); |
| 161 EXPECT_SUBSTRING("badIdent", Dart_GetError(result)); | 161 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); |
| 162 | 162 |
| 163 result = Dart_Invoke(lib, Dart_NewString("Func2"), 0, NULL); | 163 result = Dart_Invoke(lib, Dart_NewString("Func2"), 0, NULL); |
| 164 EXPECT(Dart_IsError(result)); | 164 EXPECT(Dart_IsError(result)); |
| 165 EXPECT(Dart_ErrorHasException(result)); | 165 EXPECT(Dart_ErrorHasException(result)); |
| 166 EXPECT_SUBSTRING("myException", Dart_GetError(result)); | 166 EXPECT_SUBSTRING("myException", Dart_GetError(result)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 #endif | 169 #endif |
| 170 | 170 |
| 171 | 171 |
| (...skipping 6971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7143 EXPECT(o2 == reinterpret_cast<void*>(&p2)); | 7143 EXPECT(o2 == reinterpret_cast<void*>(&p2)); |
| 7144 } | 7144 } |
| 7145 Dart_ExitScope(); | 7145 Dart_ExitScope(); |
| 7146 isolate->heap()->CollectGarbage(Heap::kOld); | 7146 isolate->heap()->CollectGarbage(Heap::kOld); |
| 7147 EXPECT_EQ(0, isolate->heap()->PeerCount()); | 7147 EXPECT_EQ(0, isolate->heap()->PeerCount()); |
| 7148 } | 7148 } |
| 7149 | 7149 |
| 7150 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7150 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 7151 | 7151 |
| 7152 } // namespace dart | 7152 } // namespace dart |
| OLD | NEW |