| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 22 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 23 // Unit test case to verify error during isolate spawning (application classes | 23 // Unit test case to verify error during isolate spawning (application classes |
| 24 // not loaded into the isolate). | 24 // not loaded into the isolate). |
| 25 TEST_CASE(IsolateSpawn) { | 25 TEST_CASE(IsolateSpawn) { |
| 26 const char* kScriptChars = | 26 const char* kScriptChars = |
| 27 "#import('dart:isolate');\n" | 27 "#import('dart:isolate');\n" |
| 28 "class SpawnNewIsolate extends Isolate {\n" | 28 "class SpawnNewIsolate extends Isolate {\n" |
| 29 " SpawnNewIsolate() : super() { }\n" | 29 " SpawnNewIsolate() : super() { }\n" |
| 30 " void main() {\n" | 30 " void main() {\n" |
| 31 " }\n" | 31 " }\n" |
| 32 " static int testMain() {\n" | 32 "}\n" |
| 33 " try {\n" | 33 "int testMain() {\n" |
| 34 " new SpawnNewIsolate().spawn().then(function(SendPort port) {\n" | 34 " try {\n" |
| 35 " });\n" | 35 " new SpawnNewIsolate().spawn().then(function(SendPort port) {\n" |
| 36 " } catch (var e) {\n" | 36 " });\n" |
| 37 " throw;\n" | 37 " } catch (var e) {\n" |
| 38 " }\n" | 38 " throw;\n" |
| 39 " return 0;\n" | |
| 40 " }\n" | 39 " }\n" |
| 40 " return 0;\n" |
| 41 "}\n"; | 41 "}\n"; |
| 42 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 42 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 43 Dart_Handle result = Dart_InvokeStatic(lib, | 43 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); |
| 44 Dart_NewString("SpawnNewIsolate"), | |
| 45 Dart_NewString("testMain"), | |
| 46 0, | |
| 47 NULL); | |
| 48 EXPECT(Dart_IsError(result)); | 44 EXPECT(Dart_IsError(result)); |
| 49 EXPECT(Dart_ErrorHasException(result)); | 45 EXPECT(Dart_ErrorHasException(result)); |
| 50 Dart_Handle exception_result = Dart_ErrorGetException(result); | 46 Dart_Handle exception_result = Dart_ErrorGetException(result); |
| 51 EXPECT_VALID(exception_result); | 47 EXPECT_VALID(exception_result); |
| 52 } | 48 } |
| 53 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 49 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 54 | 50 |
| 55 } // namespace dart | 51 } // namespace dart |
| OLD | NEW |