Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 2666133002: Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run w… (Closed)
Patch Set: Fixed name of UNIT_TEST_CASE macro Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 TransitionNativeToVM transition(thread); 2479 TransitionNativeToVM transition(thread);
2480 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 2480 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
2481 GCTestHelper::WaitForGCTasks(); 2481 GCTestHelper::WaitForGCTasks();
2482 EXPECT(peer == 42); 2482 EXPECT(peer == 42);
2483 } 2483 }
2484 } 2484 }
2485 2485
2486 2486
2487 // Unit test for entering a scope, creating a local handle and exiting 2487 // Unit test for entering a scope, creating a local handle and exiting
2488 // the scope. 2488 // the scope.
2489 UNIT_TEST_CASE(EnterExitScope) { 2489 VM_UNIT_TEST_CASE(EnterExitScope) {
2490 TestIsolateScope __test_isolate__; 2490 TestIsolateScope __test_isolate__;
2491 2491
2492 Thread* thread = Thread::Current(); 2492 Thread* thread = Thread::Current();
2493 EXPECT(thread != NULL); 2493 EXPECT(thread != NULL);
2494 ApiLocalScope* scope = thread->api_top_scope(); 2494 ApiLocalScope* scope = thread->api_top_scope();
2495 Dart_EnterScope(); 2495 Dart_EnterScope();
2496 { 2496 {
2497 EXPECT(thread->api_top_scope() != NULL); 2497 EXPECT(thread->api_top_scope() != NULL);
2498 HANDLESCOPE(thread); 2498 HANDLESCOPE(thread);
2499 const String& str1 = String::Handle(String::New("Test String")); 2499 const String& str1 = String::Handle(String::New("Test String"));
2500 Dart_Handle ref = Api::NewHandle(thread, str1.raw()); 2500 Dart_Handle ref = Api::NewHandle(thread, str1.raw());
2501 String& str2 = String::Handle(); 2501 String& str2 = String::Handle();
2502 str2 ^= Api::UnwrapHandle(ref); 2502 str2 ^= Api::UnwrapHandle(ref);
2503 EXPECT(str1.Equals(str2)); 2503 EXPECT(str1.Equals(str2));
2504 } 2504 }
2505 Dart_ExitScope(); 2505 Dart_ExitScope();
2506 EXPECT(scope == thread->api_top_scope()); 2506 EXPECT(scope == thread->api_top_scope());
2507 } 2507 }
2508 2508
2509 2509
2510 // Unit test for creating and deleting persistent handles. 2510 // Unit test for creating and deleting persistent handles.
2511 UNIT_TEST_CASE(PersistentHandles) { 2511 VM_UNIT_TEST_CASE(PersistentHandles) {
2512 const char* kTestString1 = "Test String1"; 2512 const char* kTestString1 = "Test String1";
2513 const char* kTestString2 = "Test String2"; 2513 const char* kTestString2 = "Test String2";
2514 TestCase::CreateTestIsolate(); 2514 TestCase::CreateTestIsolate();
2515 Thread* thread = Thread::Current(); 2515 Thread* thread = Thread::Current();
2516 Isolate* isolate = thread->isolate(); 2516 Isolate* isolate = thread->isolate();
2517 EXPECT(isolate != NULL); 2517 EXPECT(isolate != NULL);
2518 ApiState* state = isolate->api_state(); 2518 ApiState* state = isolate->api_state();
2519 EXPECT(state != NULL); 2519 EXPECT(state != NULL);
2520 ApiLocalScope* scope = thread->api_top_scope(); 2520 ApiLocalScope* scope = thread->api_top_scope();
2521 Dart_PersistentHandle handles[2000]; 2521 Dart_PersistentHandle handles[2000];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 } 2570 }
2571 } 2571 }
2572 EXPECT(scope == thread->api_top_scope()); 2572 EXPECT(scope == thread->api_top_scope());
2573 EXPECT_EQ(2001, state->CountPersistentHandles()); 2573 EXPECT_EQ(2001, state->CountPersistentHandles());
2574 Dart_ShutdownIsolate(); 2574 Dart_ShutdownIsolate();
2575 } 2575 }
2576 2576
2577 2577
2578 // Test that we are able to create a persistent handle from a 2578 // Test that we are able to create a persistent handle from a
2579 // persistent handle. 2579 // persistent handle.
2580 UNIT_TEST_CASE(NewPersistentHandle_FromPersistentHandle) { 2580 VM_UNIT_TEST_CASE(NewPersistentHandle_FromPersistentHandle) {
2581 TestIsolateScope __test_isolate__; 2581 TestIsolateScope __test_isolate__;
2582 2582
2583 Isolate* isolate = Isolate::Current(); 2583 Isolate* isolate = Isolate::Current();
2584 EXPECT(isolate != NULL); 2584 EXPECT(isolate != NULL);
2585 ApiState* state = isolate->api_state(); 2585 ApiState* state = isolate->api_state();
2586 EXPECT(state != NULL); 2586 EXPECT(state != NULL);
2587 Thread* thread = Thread::Current(); 2587 Thread* thread = Thread::Current();
2588 CHECK_API_SCOPE(thread); 2588 CHECK_API_SCOPE(thread);
2589 HANDLESCOPE(thread); 2589 HANDLESCOPE(thread);
2590 2590
(...skipping 10 matching lines...) Expand all
2601 Dart_Handle obj4 = Dart_HandleFromPersistent(obj3); 2601 Dart_Handle obj4 = Dart_HandleFromPersistent(obj3);
2602 EXPECT(Dart_IsBoolean(obj4)); 2602 EXPECT(Dart_IsBoolean(obj4));
2603 bool value = false; 2603 bool value = false;
2604 Dart_Handle result = Dart_BooleanValue(obj4, &value); 2604 Dart_Handle result = Dart_BooleanValue(obj4, &value);
2605 EXPECT_VALID(result); 2605 EXPECT_VALID(result);
2606 EXPECT(value); 2606 EXPECT(value);
2607 } 2607 }
2608 2608
2609 2609
2610 // Test that we can assign to a persistent handle. 2610 // Test that we can assign to a persistent handle.
2611 UNIT_TEST_CASE(AssignToPersistentHandle) { 2611 VM_UNIT_TEST_CASE(AssignToPersistentHandle) {
2612 const char* kTestString1 = "Test String1"; 2612 const char* kTestString1 = "Test String1";
2613 const char* kTestString2 = "Test String2"; 2613 const char* kTestString2 = "Test String2";
2614 TestIsolateScope __test_isolate__; 2614 TestIsolateScope __test_isolate__;
2615 2615
2616 Thread* T = Thread::Current(); 2616 Thread* T = Thread::Current();
2617 CHECK_API_SCOPE(T); 2617 CHECK_API_SCOPE(T);
2618 HANDLESCOPE(T); 2618 HANDLESCOPE(T);
2619 Isolate* isolate = T->isolate(); 2619 Isolate* isolate = T->isolate();
2620 EXPECT(isolate != NULL); 2620 EXPECT(isolate != NULL);
2621 ApiState* state = isolate->api_state(); 2621 ApiState* state = isolate->api_state();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 TransitionNativeToVM transition(thread); 2859 TransitionNativeToVM transition(thread);
2860 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2860 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2861 EXPECT(peer == 0); 2861 EXPECT(peer == 0);
2862 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); 2862 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2863 GCTestHelper::WaitForGCTasks(); 2863 GCTestHelper::WaitForGCTasks();
2864 EXPECT(peer == 0); 2864 EXPECT(peer == 0);
2865 } 2865 }
2866 } 2866 }
2867 2867
2868 2868
2869 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { 2869 VM_UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) {
2870 TestCase::CreateTestIsolate(); 2870 TestCase::CreateTestIsolate();
2871 Dart_EnterScope(); 2871 Dart_EnterScope();
2872 Dart_Handle ref = Dart_True(); 2872 Dart_Handle ref = Dart_True();
2873 int peer = 1234; 2873 int peer = 1234;
2874 Dart_NewWeakPersistentHandle(ref, &peer, 0, 2874 Dart_NewWeakPersistentHandle(ref, &peer, 0,
2875 WeakPersistentHandlePeerFinalizer); 2875 WeakPersistentHandlePeerFinalizer);
2876 Dart_ExitScope(); 2876 Dart_ExitScope();
2877 Dart_ShutdownIsolate(); 2877 Dart_ShutdownIsolate();
2878 EXPECT(peer == 42); 2878 EXPECT(peer == 42);
2879 } 2879 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 3356 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
3357 EXPECT_EQ(3, global_prologue_callback_status); 3357 EXPECT_EQ(3, global_prologue_callback_status);
3358 EXPECT_EQ(7, global_epilogue_callback_status); 3358 EXPECT_EQ(7, global_epilogue_callback_status);
3359 } 3359 }
3360 } 3360 }
3361 3361
3362 3362
3363 // Unit test for creating multiple scopes and local handles within them. 3363 // Unit test for creating multiple scopes and local handles within them.
3364 // Ensure that the local handles get all cleaned out when exiting the 3364 // Ensure that the local handles get all cleaned out when exiting the
3365 // scope. 3365 // scope.
3366 UNIT_TEST_CASE(LocalHandles) { 3366 VM_UNIT_TEST_CASE(LocalHandles) {
3367 TestCase::CreateTestIsolate(); 3367 TestCase::CreateTestIsolate();
3368 Thread* thread = Thread::Current(); 3368 Thread* thread = Thread::Current();
3369 Isolate* isolate = thread->isolate(); 3369 Isolate* isolate = thread->isolate();
3370 EXPECT(isolate != NULL); 3370 EXPECT(isolate != NULL);
3371 ApiLocalScope* scope = thread->api_top_scope(); 3371 ApiLocalScope* scope = thread->api_top_scope();
3372 Dart_Handle handles[300]; 3372 Dart_Handle handles[300];
3373 { 3373 {
3374 StackZone zone(thread); 3374 StackZone zone(thread);
3375 HANDLESCOPE(thread); 3375 HANDLESCOPE(thread);
3376 Smi& val = Smi::Handle(); 3376 Smi& val = Smi::Handle();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3420 } 3420 }
3421 EXPECT_EQ(0, thread->CountLocalHandles()); 3421 EXPECT_EQ(0, thread->CountLocalHandles());
3422 EXPECT(scope == thread->api_top_scope()); 3422 EXPECT(scope == thread->api_top_scope());
3423 Dart_ShutdownIsolate(); 3423 Dart_ShutdownIsolate();
3424 } 3424 }
3425 3425
3426 3426
3427 // Unit test for creating multiple scopes and allocating objects in the 3427 // Unit test for creating multiple scopes and allocating objects in the
3428 // zone for the scope. Ensure that the memory is freed when the scope 3428 // zone for the scope. Ensure that the memory is freed when the scope
3429 // exits. 3429 // exits.
3430 UNIT_TEST_CASE(LocalZoneMemory) { 3430 VM_UNIT_TEST_CASE(LocalZoneMemory) {
3431 TestCase::CreateTestIsolate(); 3431 TestCase::CreateTestIsolate();
3432 Thread* thread = Thread::Current(); 3432 Thread* thread = Thread::Current();
3433 EXPECT(thread != NULL); 3433 EXPECT(thread != NULL);
3434 ApiLocalScope* scope = thread->api_top_scope(); 3434 ApiLocalScope* scope = thread->api_top_scope();
3435 { 3435 {
3436 // Start a new scope and allocate some memory. 3436 // Start a new scope and allocate some memory.
3437 Dart_EnterScope(); 3437 Dart_EnterScope();
3438 for (int i = 0; i < 100; i++) { 3438 for (int i = 0; i < 100; i++) {
3439 Dart_ScopeAllocate(16); 3439 Dart_ScopeAllocate(16);
3440 } 3440 }
(...skipping 21 matching lines...) Expand all
3462 } 3462 }
3463 EXPECT_EQ(1600, thread->ZoneSizeInBytes()); 3463 EXPECT_EQ(1600, thread->ZoneSizeInBytes());
3464 Dart_ExitScope(); 3464 Dart_ExitScope();
3465 } 3465 }
3466 EXPECT_EQ(0, thread->ZoneSizeInBytes()); 3466 EXPECT_EQ(0, thread->ZoneSizeInBytes());
3467 EXPECT(scope == thread->api_top_scope()); 3467 EXPECT(scope == thread->api_top_scope());
3468 Dart_ShutdownIsolate(); 3468 Dart_ShutdownIsolate();
3469 } 3469 }
3470 3470
3471 3471
3472 UNIT_TEST_CASE(Isolates) { 3472 VM_UNIT_TEST_CASE(Isolates) {
3473 // This test currently assumes that the Dart_Isolate type is an opaque 3473 // This test currently assumes that the Dart_Isolate type is an opaque
3474 // representation of Isolate*. 3474 // representation of Isolate*.
3475 Dart_Isolate iso_1 = TestCase::CreateTestIsolate(); 3475 Dart_Isolate iso_1 = TestCase::CreateTestIsolate();
3476 EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current())); 3476 EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current()));
3477 Dart_Isolate isolate = Dart_CurrentIsolate(); 3477 Dart_Isolate isolate = Dart_CurrentIsolate();
3478 EXPECT_EQ(iso_1, isolate); 3478 EXPECT_EQ(iso_1, isolate);
3479 Dart_ExitIsolate(); 3479 Dart_ExitIsolate();
3480 EXPECT(NULL == Dart_CurrentIsolate()); 3480 EXPECT(NULL == Dart_CurrentIsolate());
3481 Dart_Isolate iso_2 = TestCase::CreateTestIsolate(); 3481 Dart_Isolate iso_2 = TestCase::CreateTestIsolate();
3482 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); 3482 EXPECT_EQ(iso_2, Dart_CurrentIsolate());
3483 Dart_ExitIsolate(); 3483 Dart_ExitIsolate();
3484 EXPECT(NULL == Dart_CurrentIsolate()); 3484 EXPECT(NULL == Dart_CurrentIsolate());
3485 Dart_EnterIsolate(iso_2); 3485 Dart_EnterIsolate(iso_2);
3486 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); 3486 EXPECT_EQ(iso_2, Dart_CurrentIsolate());
3487 Dart_ShutdownIsolate(); 3487 Dart_ShutdownIsolate();
3488 EXPECT(NULL == Dart_CurrentIsolate()); 3488 EXPECT(NULL == Dart_CurrentIsolate());
3489 Dart_EnterIsolate(iso_1); 3489 Dart_EnterIsolate(iso_1);
3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); 3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate());
3491 Dart_ShutdownIsolate(); 3491 Dart_ShutdownIsolate();
3492 EXPECT(NULL == Dart_CurrentIsolate()); 3492 EXPECT(NULL == Dart_CurrentIsolate());
3493 } 3493 }
3494 3494
3495 3495
3496 UNIT_TEST_CASE(CurrentIsolateData) { 3496 VM_UNIT_TEST_CASE(CurrentIsolateData) {
3497 intptr_t mydata = 12345; 3497 intptr_t mydata = 12345;
3498 char* err; 3498 char* err;
3499 Dart_Isolate isolate = 3499 Dart_Isolate isolate =
3500 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, 3500 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data,
3501 bin::core_isolate_snapshot_instructions, NULL, 3501 bin::core_isolate_snapshot_instructions, NULL,
3502 reinterpret_cast<void*>(mydata), &err); 3502 reinterpret_cast<void*>(mydata), &err);
3503 EXPECT(isolate != NULL); 3503 EXPECT(isolate != NULL);
3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); 3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData()));
3505 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); 3505 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate)));
3506 Dart_ShutdownIsolate(); 3506 Dart_ShutdownIsolate();
3507 } 3507 }
3508 3508
3509 3509
3510 UNIT_TEST_CASE(IsolateSetCheckedMode) { 3510 VM_UNIT_TEST_CASE(IsolateSetCheckedMode) {
3511 const char* kScriptChars = 3511 const char* kScriptChars =
3512 "int bad1() {\n" 3512 "int bad1() {\n"
3513 " int foo = 'string';\n" 3513 " int foo = 'string';\n"
3514 " return foo;\n" 3514 " return foo;\n"
3515 "}\n" 3515 "}\n"
3516 "\n" 3516 "\n"
3517 "int good1() {\n" 3517 "int good1() {\n"
3518 " int five = 5;\n" 3518 " int five = 5;\n"
3519 " return five;" 3519 " return five;"
3520 "}\n"; 3520 "}\n";
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 TEST_CASE(DebugName) { 3567 TEST_CASE(DebugName) {
3568 Dart_Handle debug_name = Dart_DebugName(); 3568 Dart_Handle debug_name = Dart_DebugName();
3569 EXPECT_VALID(debug_name); 3569 EXPECT_VALID(debug_name);
3570 EXPECT(Dart_IsString(debug_name)); 3570 EXPECT(Dart_IsString(debug_name));
3571 } 3571 }
3572 3572
3573 3573
3574 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {} 3574 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {}
3575 3575
3576 3576
3577 UNIT_TEST_CASE(SetMessageCallbacks) { 3577 VM_UNIT_TEST_CASE(SetMessageCallbacks) {
3578 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); 3578 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
3579 Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback); 3579 Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback);
3580 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); 3580 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
3581 EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback()); 3581 EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback());
3582 Dart_ShutdownIsolate(); 3582 Dart_ShutdownIsolate();
3583 } 3583 }
3584 3584
3585 3585
3586 TEST_CASE(SetStickyError) { 3586 TEST_CASE(SetStickyError) {
3587 const char* kScriptChars = "main() => throw 'HI';"; 3587 const char* kScriptChars = "main() => throw 'HI';";
(...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after
7189 } 7189 }
7190 7190
7191 7191
7192 TEST_CASE(IllegalPost) { 7192 TEST_CASE(IllegalPost) {
7193 Dart_Handle message = Dart_True(); 7193 Dart_Handle message = Dart_True();
7194 bool success = Dart_Post(ILLEGAL_PORT, message); 7194 bool success = Dart_Post(ILLEGAL_PORT, message);
7195 EXPECT(!success); 7195 EXPECT(!success);
7196 } 7196 }
7197 7197
7198 7198
7199 UNIT_TEST_CASE(NewNativePort) { 7199 VM_UNIT_TEST_CASE(NewNativePort) {
7200 // Create a port with a bogus handler. 7200 // Create a port with a bogus handler.
7201 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); 7201 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
7202 EXPECT_EQ(ILLEGAL_PORT, error_port); 7202 EXPECT_EQ(ILLEGAL_PORT, error_port);
7203 7203
7204 // Create the port w/o a current isolate, just to make sure that works. 7204 // Create the port w/o a current isolate, just to make sure that works.
7205 Dart_Port port_id1 = 7205 Dart_Port port_id1 =
7206 Dart_NewNativePort("Port123", NewNativePort_send123, true); 7206 Dart_NewNativePort("Port123", NewNativePort_send123, true);
7207 7207
7208 TestIsolateScope __test_isolate__; 7208 TestIsolateScope __test_isolate__;
7209 const char* kScriptChars = 7209 const char* kScriptChars =
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
7511 EXPECT_VALID(result); 7511 EXPECT_VALID(result);
7512 } 7512 }
7513 7513
7514 Dart_ExitScope(); 7514 Dart_ExitScope();
7515 Dart_ShutdownIsolate(); 7515 Dart_ShutdownIsolate();
7516 7516
7517 Isolate::SetCreateCallback(saved); 7517 Isolate::SetCreateCallback(saved);
7518 } 7518 }
7519 7519
7520 7520
7521 UNIT_TEST_CASE(RunLoop_Success) { 7521 VM_UNIT_TEST_CASE(RunLoop_Success) {
7522 RunLoopTest(false); 7522 RunLoopTest(false);
7523 } 7523 }
7524 7524
7525 7525
7526 UNIT_TEST_CASE(RunLoop_Exception) { 7526 VM_UNIT_TEST_CASE(RunLoop_Exception) {
7527 RunLoopTest(true); 7527 RunLoopTest(true);
7528 } 7528 }
7529 7529
7530 7530
7531 // Utility functions and variables for test case IsolateInterrupt starts here. 7531 // Utility functions and variables for test case IsolateInterrupt starts here.
7532 static Monitor* sync = NULL; 7532 static Monitor* sync = NULL;
7533 static Dart_Isolate shared_isolate = NULL; 7533 static Dart_Isolate shared_isolate = NULL;
7534 static bool main_entered = false; 7534 static bool main_entered = false;
7535 7535
7536 7536
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
7609 ml.Notify(); 7609 ml.Notify();
7610 } 7610 }
7611 } 7611 }
7612 7612
7613 7613
7614 static void* saved_callback_data; 7614 static void* saved_callback_data;
7615 static void IsolateShutdownTestCallback(void* callback_data) { 7615 static void IsolateShutdownTestCallback(void* callback_data) {
7616 saved_callback_data = callback_data; 7616 saved_callback_data = callback_data;
7617 } 7617 }
7618 7618
7619 UNIT_TEST_CASE(IsolateShutdown) { 7619 VM_UNIT_TEST_CASE(IsolateShutdown) {
7620 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); 7620 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback();
7621 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); 7621 Isolate::SetShutdownCallback(IsolateShutdownTestCallback);
7622 7622
7623 saved_callback_data = NULL; 7623 saved_callback_data = NULL;
7624 7624
7625 void* my_data = reinterpret_cast<void*>(12345); 7625 void* my_data = reinterpret_cast<void*>(12345);
7626 7626
7627 // Create an isolate. 7627 // Create an isolate.
7628 char* err; 7628 char* err;
7629 Dart_Isolate isolate = Dart_CreateIsolate( 7629 Dart_Isolate isolate = Dart_CreateIsolate(
(...skipping 27 matching lines...) Expand all
7657 Dart_Handle arg2 = Dart_NewInteger(9); 7657 Dart_Handle arg2 = Dart_NewInteger(9);
7658 EXPECT_VALID(arg2); 7658 EXPECT_VALID(arg2);
7659 Dart_Handle dart_args[2] = {arg1, arg2}; 7659 Dart_Handle dart_args[2] = {arg1, arg2};
7660 Dart_Handle result = Dart_Invoke(lib, NewString("add"), 2, dart_args); 7660 Dart_Handle result = Dart_Invoke(lib, NewString("add"), 2, dart_args);
7661 EXPECT_VALID(result); 7661 EXPECT_VALID(result);
7662 result = Dart_IntegerToInt64(result, &add_result); 7662 result = Dart_IntegerToInt64(result, &add_result);
7663 EXPECT_VALID(result); 7663 EXPECT_VALID(result);
7664 Dart_ExitScope(); 7664 Dart_ExitScope();
7665 } 7665 }
7666 7666
7667 UNIT_TEST_CASE(IsolateShutdownRunDartCode) { 7667 VM_UNIT_TEST_CASE(IsolateShutdownRunDartCode) {
7668 const char* kScriptChars = 7668 const char* kScriptChars =
7669 "int add(int a, int b) {\n" 7669 "int add(int a, int b) {\n"
7670 " return a + b;\n" 7670 " return a + b;\n"
7671 "}\n" 7671 "}\n"
7672 "\n" 7672 "\n"
7673 "void main() {\n" 7673 "void main() {\n"
7674 " add(4, 5);\n" 7674 " add(4, 5);\n"
7675 "}\n"; 7675 "}\n";
7676 7676
7677 // Create an isolate. 7677 // Create an isolate.
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
9914 EXPECT_VALID(result); 9914 EXPECT_VALID(result);
9915 result = Dart_FinalizeLoading(false); 9915 result = Dart_FinalizeLoading(false);
9916 EXPECT_VALID(result); 9916 EXPECT_VALID(result);
9917 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); 9917 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL);
9918 EXPECT(Dart_IsError(result)); 9918 EXPECT(Dart_IsError(result));
9919 } 9919 }
9920 9920
9921 #endif // !PRODUCT 9921 #endif // !PRODUCT
9922 9922
9923 } // namespace dart 9923 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/custom_isolate_test.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698