| 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 "platform/assert.h" | 6 #include "platform/assert.h" |
| 6 #include "vm/globals.h" | 7 #include "vm/globals.h" |
| 7 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 8 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
| 9 | 10 |
| 10 namespace dart { | 11 namespace dart { |
| 11 | 12 |
| 12 UNIT_TEST_CASE(IsolateCurrent) { | 13 UNIT_TEST_CASE(IsolateCurrent) { |
| 13 Isolate::Flags vm_flags; | 14 Dart_Isolate isolate = Dart_CreateIsolate( |
| 14 Dart_IsolateFlags api_flags; | 15 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL); |
| 15 vm_flags.CopyTo(&api_flags); | 16 EXPECT_EQ(isolate, Dart_CurrentIsolate()); |
| 16 Isolate* isolate = Isolate::Init(NULL, api_flags); | 17 Dart_ShutdownIsolate(); |
| 17 EXPECT_EQ(isolate, Isolate::Current()); | 18 EXPECT_EQ(reinterpret_cast<Dart_Isolate>(NULL), Dart_CurrentIsolate()); |
| 18 isolate->Shutdown(); | |
| 19 EXPECT_EQ(reinterpret_cast<Isolate*>(NULL), Isolate::Current()); | |
| 20 delete isolate; | |
| 21 } | 19 } |
| 22 | 20 |
| 23 | 21 |
| 24 // Test to ensure that an exception is thrown if no isolate creation | 22 // Test to ensure that an exception is thrown if no isolate creation |
| 25 // callback has been set by the embedder when an isolate is spawned. | 23 // callback has been set by the embedder when an isolate is spawned. |
| 26 TEST_CASE(IsolateSpawn) { | 24 TEST_CASE(IsolateSpawn) { |
| 27 const char* kScriptChars = | 25 const char* kScriptChars = |
| 28 "import 'dart:isolate';\n" | 26 "import 'dart:isolate';\n" |
| 29 // Ignores printed lines. | 27 // Ignores printed lines. |
| 30 "var _nullPrintClosure = (String line) {};\n" | 28 "var _nullPrintClosure = (String line) {};\n" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 EXPECT(!Dart_IsError(result)); | 74 EXPECT(!Dart_IsError(result)); |
| 77 // Run until all ports to isolate are closed. | 75 // Run until all ports to isolate are closed. |
| 78 result = Dart_RunLoop(); | 76 result = Dart_RunLoop(); |
| 79 EXPECT_ERROR(result, "Null callback specified for isolate creation"); | 77 EXPECT_ERROR(result, "Null callback specified for isolate creation"); |
| 80 EXPECT(Dart_ErrorHasException(result)); | 78 EXPECT(Dart_ErrorHasException(result)); |
| 81 Dart_Handle exception_result = Dart_ErrorGetException(result); | 79 Dart_Handle exception_result = Dart_ErrorGetException(result); |
| 82 EXPECT_VALID(exception_result); | 80 EXPECT_VALID(exception_result); |
| 83 } | 81 } |
| 84 | 82 |
| 85 } // namespace dart | 83 } // namespace dart |
| OLD | NEW |