| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_UNIT_TEST_H_ | 5 #ifndef VM_UNIT_TEST_H_ |
| 6 #define VM_UNIT_TEST_H_ | 6 #define VM_UNIT_TEST_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "vm/ast.h" | 10 #include "vm/ast.h" |
| 11 #include "vm/dart.h" | 11 #include "vm/dart.h" |
| 12 #include "vm/globals.h" | 12 #include "vm/globals.h" |
| 13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
| 14 #include "vm/isolate.h" | 14 #include "vm/isolate.h" |
| 15 #include "vm/longjump.h" |
| 15 #include "vm/object.h" | 16 #include "vm/object.h" |
| 16 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 17 #include "vm/zone.h" | 18 #include "vm/zone.h" |
| 18 | 19 |
| 19 // The UNIT_TEST_CASE macro is used for tests that do not need any | 20 // The UNIT_TEST_CASE macro is used for tests that do not need any |
| 20 // default isolate or zone functionality. | 21 // default isolate or zone functionality. |
| 21 #define UNIT_TEST_CASE(name) \ | 22 #define UNIT_TEST_CASE(name) \ |
| 22 void Dart_Test##name(); \ | 23 void Dart_Test##name(); \ |
| 23 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \ | 24 static const dart::TestCase kRegister##name(Dart_Test##name, #name); \ |
| 24 void Dart_Test##name() | 25 void Dart_Test##name() |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 virtual void Run(); | 166 virtual void Run(); |
| 166 | 167 |
| 167 private: | 168 private: |
| 168 RunEntry* const run_; | 169 RunEntry* const run_; |
| 169 }; | 170 }; |
| 170 | 171 |
| 171 | 172 |
| 172 class TestIsolateScope { | 173 class TestIsolateScope { |
| 173 public: | 174 public: |
| 174 TestIsolateScope() { | 175 TestIsolateScope() { |
| 175 isolate_ = Dart::CreateIsolate(NULL, NULL); | 176 isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL)); |
| 177 EXPECT(isolate_ != NULL); |
| 176 Dart_EnterScope(); // Create a Dart API scope for unit tests. | 178 Dart_EnterScope(); // Create a Dart API scope for unit tests. |
| 177 } | 179 } |
| 178 ~TestIsolateScope() { | 180 ~TestIsolateScope() { |
| 179 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. | 181 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. |
| 180 ASSERT(isolate_ == Isolate::Current()); | 182 ASSERT(isolate_ == Isolate::Current()); |
| 181 Dart::ShutdownIsolate(); | 183 Dart_ShutdownIsolate(); |
| 182 isolate_ = NULL; | 184 isolate_ = NULL; |
| 183 } | 185 } |
| 184 | 186 |
| 185 private: | 187 private: |
| 186 Isolate* isolate_; | 188 Isolate* isolate_; |
| 187 | 189 |
| 188 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope); | 190 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope); |
| 189 }; | 191 }; |
| 190 | 192 |
| 191 | 193 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 253 |
| 252 #define EXPECT_VALID(handle) \ | 254 #define EXPECT_VALID(handle) \ |
| 253 if (!Dart_IsValid((handle))) { \ | 255 if (!Dart_IsValid((handle))) { \ |
| 254 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ | 256 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ |
| 255 #handle, Dart_GetError(handle)); \ | 257 #handle, Dart_GetError(handle)); \ |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace dart | 260 } // namespace dart |
| 259 | 261 |
| 260 #endif // VM_UNIT_TEST_H_ | 262 #endif // VM_UNIT_TEST_H_ |
| OLD | NEW |