| 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 EXPECT_EQ(iso_2, Isolate::Current()); | 441 EXPECT_EQ(iso_2, Isolate::Current()); |
| 442 Dart_ShutdownIsolate(); | 442 Dart_ShutdownIsolate(); |
| 443 EXPECT(NULL == Isolate::Current()); | 443 EXPECT(NULL == Isolate::Current()); |
| 444 Dart_EnterIsolate(iso_1); | 444 Dart_EnterIsolate(iso_1); |
| 445 EXPECT_EQ(iso_1, Isolate::Current()); | 445 EXPECT_EQ(iso_1, Isolate::Current()); |
| 446 Dart_ShutdownIsolate(); | 446 Dart_ShutdownIsolate(); |
| 447 EXPECT(NULL == Isolate::Current()); | 447 EXPECT(NULL == Isolate::Current()); |
| 448 } | 448 } |
| 449 | 449 |
| 450 | 450 |
| 451 static bool MyPostMessageCallback(Dart_Isolate dest_isolate, |
| 452 Dart_Port send_port, |
| 453 Dart_Port reply_port, |
| 454 Dart_Message message) { |
| 455 return true; |
| 456 } |
| 457 |
| 458 |
| 459 UNIT_TEST_CASE(SetPostMessageCallback) { |
| 460 Dart_Isolate dart_isolate = Dart_CreateIsolate(NULL, NULL); |
| 461 Dart_SetPostMessageCallback(&MyPostMessageCallback); |
| 462 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
| 463 EXPECT_EQ(&MyPostMessageCallback, isolate->post_message_callback()); |
| 464 Dart_ShutdownIsolate(); |
| 465 } |
| 466 |
| 467 |
| 468 static void MyClosePortCallback(Dart_Isolate dest_isolate, |
| 469 Dart_Port port) { |
| 470 } |
| 471 |
| 472 |
| 473 UNIT_TEST_CASE(SetClosePortCallback) { |
| 474 Dart_Isolate dart_isolate = Dart_CreateIsolate(NULL, NULL); |
| 475 Dart_SetClosePortCallback(&MyClosePortCallback); |
| 476 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
| 477 EXPECT_EQ(&MyClosePortCallback, isolate->close_port_callback()); |
| 478 Dart_ShutdownIsolate(); |
| 479 } |
| 480 |
| 481 |
| 451 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. | 482 #if defined(TARGET_ARCH_IA32) // only ia32 can run execution tests. |
| 452 | 483 |
| 453 UNIT_TEST_CASE(FieldAccess) { | 484 UNIT_TEST_CASE(FieldAccess) { |
| 454 const char* kScriptChars = | 485 const char* kScriptChars = |
| 455 "class Fields {\n" | 486 "class Fields {\n" |
| 456 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" | 487 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 457 " int fld1;\n" | 488 " int fld1;\n" |
| 458 " final int fld2;\n" | 489 " final int fld2;\n" |
| 459 " static int fld3;\n" | 490 " static int fld3;\n" |
| 460 " static final int fld4 = 10;\n" | 491 " static final int fld4 = 10;\n" |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 retobj = Dart_GetResult(result); | 1424 retobj = Dart_GetResult(result); |
| 1394 EXPECT(Dart_ExceptionOccurred(retobj)); */ | 1425 EXPECT(Dart_ExceptionOccurred(retobj)); */ |
| 1395 } | 1426 } |
| 1396 Dart_ExitScope(); // Exit the Dart API scope. | 1427 Dart_ExitScope(); // Exit the Dart API scope. |
| 1397 Dart_ShutdownIsolate(); | 1428 Dart_ShutdownIsolate(); |
| 1398 } | 1429 } |
| 1399 | 1430 |
| 1400 #endif // TARGET_ARCH_IA32. | 1431 #endif // TARGET_ARCH_IA32. |
| 1401 | 1432 |
| 1402 } // namespace dart | 1433 } // namespace dart |
| OLD | NEW |