| 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_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 | 9 |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| 11 | 11 |
| 12 #include "vm/ast.h" | 12 #include "vm/ast.h" |
| 13 #include "vm/dart.h" | 13 #include "vm/dart.h" |
| 14 #include "vm/dart_api_impl.h" |
| 14 #include "vm/globals.h" | 15 #include "vm/globals.h" |
| 15 #include "vm/heap.h" | 16 #include "vm/heap.h" |
| 16 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
| 17 #include "vm/longjump.h" | 18 #include "vm/longjump.h" |
| 18 #include "vm/object.h" | 19 #include "vm/object.h" |
| 19 #include "vm/object_store.h" | 20 #include "vm/object_store.h" |
| 20 #include "vm/simulator.h" | 21 #include "vm/simulator.h" |
| 21 #include "vm/zone.h" | 22 #include "vm/zone.h" |
| 22 | 23 |
| 23 // The UNIT_TEST_CASE macro is used for tests that do not need any | 24 // The UNIT_TEST_CASE macro is used for tests that do not need any |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 Dart_Handle url); | 281 Dart_Handle url); |
| 281 static char* BigintToHexValue(Dart_CObject* bigint); | 282 static char* BigintToHexValue(Dart_CObject* bigint); |
| 282 | 283 |
| 283 virtual void Run(); | 284 virtual void Run(); |
| 284 | 285 |
| 285 private: | 286 private: |
| 286 static Dart_Isolate CreateIsolate(const uint8_t* buffer, | 287 static Dart_Isolate CreateIsolate(const uint8_t* buffer, |
| 287 const char* name) { | 288 const char* name) { |
| 288 char* err; | 289 char* err; |
| 289 Dart_Isolate isolate = Dart_CreateIsolate(name, NULL, buffer, NULL, &err); | 290 Dart_Isolate isolate = Dart_CreateIsolate(name, NULL, buffer, NULL, &err); |
| 290 if (isolate == NULL) { | 291 if (isolate == DART_ILLEGAL_ISOLATE) { |
| 291 OS::Print("Creation of isolate failed '%s'\n", err); | 292 OS::Print("Creation of isolate failed '%s'\n", err); |
| 292 free(err); | 293 free(err); |
| 293 } | 294 } |
| 294 EXPECT(isolate != NULL); | 295 EXPECT(isolate != DART_ILLEGAL_ISOLATE); |
| 295 return isolate; | 296 return isolate; |
| 296 } | 297 } |
| 297 | 298 |
| 298 RunEntry* const run_; | 299 RunEntry* const run_; |
| 299 }; | 300 }; |
| 300 | 301 |
| 301 | 302 |
| 302 class TestIsolateScope { | 303 class TestIsolateScope { |
| 303 public: | 304 public: |
| 304 TestIsolateScope() { | 305 TestIsolateScope() { |
| 305 isolate_ = reinterpret_cast<Isolate*>(TestCase::CreateTestIsolate()); | 306 isolate_ = TestCase::CreateTestIsolate(); |
| 306 Dart_EnterScope(); // Create a Dart API scope for unit tests. | 307 Dart_EnterScope(); // Create a Dart API scope for unit tests. |
| 307 } | 308 } |
| 308 ~TestIsolateScope() { | 309 ~TestIsolateScope() { |
| 309 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. | 310 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. |
| 310 ASSERT(isolate_ == Isolate::Current()); | 311 ASSERT(isolate_ == Api::CastIsolate(Isolate::Current())); |
| 311 Dart_ShutdownIsolate(); | 312 Dart_ShutdownIsolate(); |
| 312 isolate_ = NULL; | 313 isolate_ = DART_ILLEGAL_ISOLATE; |
| 313 } | 314 } |
| 314 Isolate* isolate() const { return isolate_; } | 315 Isolate* isolate() const { return Api::CastIsolate(isolate_); } |
| 315 | 316 |
| 316 private: | 317 private: |
| 317 Isolate* isolate_; | 318 Dart_Isolate isolate_; |
| 318 | 319 |
| 319 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope); | 320 DISALLOW_COPY_AND_ASSIGN(TestIsolateScope); |
| 320 }; | 321 }; |
| 321 | 322 |
| 322 | 323 |
| 323 class AssemblerTest { | 324 class AssemblerTest { |
| 324 public: | 325 public: |
| 325 AssemblerTest(const char* name, Assembler* assembler) | 326 AssemblerTest(const char* name, Assembler* assembler) |
| 326 : name_(name), | 327 : name_(name), |
| 327 assembler_(assembler), | 328 assembler_(assembler), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } \ | 424 } \ |
| 424 } else { \ | 425 } else { \ |
| 425 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ | 426 dart::Expect(__FILE__, __LINE__).Fail("expected True, but was '%s'\n", \ |
| 426 #handle); \ | 427 #handle); \ |
| 427 } \ | 428 } \ |
| 428 } while (0) | 429 } while (0) |
| 429 | 430 |
| 430 } // namespace dart | 431 } // namespace dart |
| 431 | 432 |
| 432 #endif // VM_UNIT_TEST_H_ | 433 #endif // VM_UNIT_TEST_H_ |
| OLD | NEW |