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