OLD | NEW |
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 "include/dart_api.h" | 6 #include "include/dart_api.h" |
7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_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 "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3667 EXPECT_EQ(1600, state->ZoneSizeInBytes()); | 3667 EXPECT_EQ(1600, state->ZoneSizeInBytes()); |
3668 Dart_ExitScope(); | 3668 Dart_ExitScope(); |
3669 } | 3669 } |
3670 EXPECT_EQ(0, state->ZoneSizeInBytes()); | 3670 EXPECT_EQ(0, state->ZoneSizeInBytes()); |
3671 EXPECT(scope == state->top_scope()); | 3671 EXPECT(scope == state->top_scope()); |
3672 Dart_ShutdownIsolate(); | 3672 Dart_ShutdownIsolate(); |
3673 } | 3673 } |
3674 | 3674 |
3675 | 3675 |
3676 UNIT_TEST_CASE(Isolates) { | 3676 UNIT_TEST_CASE(Isolates) { |
| 3677 // This test currently assumes that the Dart_Isolate type is an opaque |
| 3678 // representation of Isolate*. |
3677 Dart_Isolate iso_1 = TestCase::CreateTestIsolate(); | 3679 Dart_Isolate iso_1 = TestCase::CreateTestIsolate(); |
3678 EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current())); | 3680 EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current())); |
3679 Dart_Isolate isolate = Dart_CurrentIsolate(); | 3681 Dart_Isolate isolate = Dart_CurrentIsolate(); |
3680 EXPECT_EQ(iso_1, isolate); | 3682 EXPECT_EQ(iso_1, isolate); |
3681 Dart_ExitIsolate(); | 3683 Dart_ExitIsolate(); |
3682 EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate()); | 3684 EXPECT(NULL == Dart_CurrentIsolate()); |
3683 // Test that Dart_EnterIsolate returns an error when passed a bad isolate id. | |
3684 EXPECT(!Dart_EnterIsolate(DART_ILLEGAL_ISOLATE)); | |
3685 Dart_Isolate iso_2 = TestCase::CreateTestIsolate(); | 3685 Dart_Isolate iso_2 = TestCase::CreateTestIsolate(); |
3686 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); | 3686 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); |
3687 Dart_ExitIsolate(); | 3687 Dart_ExitIsolate(); |
3688 EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate()); | 3688 EXPECT(NULL == Dart_CurrentIsolate()); |
3689 Dart_EnterIsolate(iso_2); | 3689 Dart_EnterIsolate(iso_2); |
3690 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); | 3690 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); |
3691 Dart_ShutdownIsolate(); | 3691 Dart_ShutdownIsolate(); |
3692 EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate()); | 3692 EXPECT(NULL == Dart_CurrentIsolate()); |
3693 Dart_EnterIsolate(iso_1); | 3693 Dart_EnterIsolate(iso_1); |
3694 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); | 3694 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); |
3695 Dart_ShutdownIsolate(); | 3695 Dart_ShutdownIsolate(); |
3696 EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate()); | 3696 EXPECT(NULL == Dart_CurrentIsolate()); |
3697 } | 3697 } |
3698 | 3698 |
3699 | 3699 |
3700 UNIT_TEST_CASE(CurrentIsolateData) { | 3700 UNIT_TEST_CASE(CurrentIsolateData) { |
3701 intptr_t mydata = 12345; | 3701 intptr_t mydata = 12345; |
3702 char* err; | 3702 char* err; |
3703 // We expect that Dart_Port and Dart_Isolate are the same size. | |
3704 EXPECT_EQ(sizeof(Dart_Port), sizeof(Dart_Isolate)); | |
3705 Dart_Isolate isolate = | 3703 Dart_Isolate isolate = |
3706 Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer, | 3704 Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer, |
3707 reinterpret_cast<void*>(mydata), | 3705 reinterpret_cast<void*>(mydata), |
3708 &err); | 3706 &err); |
3709 EXPECT(isolate != DART_ILLEGAL_ISOLATE); | 3707 EXPECT(isolate != NULL); |
3710 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); | 3708 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); |
3711 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); | 3709 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); |
3712 Dart_ShutdownIsolate(); | 3710 Dart_ShutdownIsolate(); |
3713 EXPECT(Dart_IsolateData(DART_ILLEGAL_ISOLATE) == NULL); | |
3714 } | 3711 } |
3715 | 3712 |
3716 | 3713 |
3717 TEST_CASE(IsolateSetCheckedMode) { | 3714 TEST_CASE(IsolateSetCheckedMode) { |
3718 const char* kScriptChars = | 3715 const char* kScriptChars = |
3719 "int bad1() {\n" | 3716 "int bad1() {\n" |
3720 " int foo = 'string';\n" | 3717 " int foo = 'string';\n" |
3721 " return foo;\n" | 3718 " return foo;\n" |
3722 "}\n" | 3719 "}\n" |
3723 "\n" | 3720 "\n" |
(...skipping 28 matching lines...) Expand all Loading... |
3752 } | 3749 } |
3753 | 3750 |
3754 | 3751 |
3755 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) { | 3752 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) { |
3756 } | 3753 } |
3757 | 3754 |
3758 | 3755 |
3759 UNIT_TEST_CASE(SetMessageCallbacks) { | 3756 UNIT_TEST_CASE(SetMessageCallbacks) { |
3760 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); | 3757 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); |
3761 Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback); | 3758 Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback); |
3762 Isolate* isolate = Api::CastIsolate(dart_isolate); | 3759 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
3763 EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback()); | 3760 EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback()); |
3764 Dart_ShutdownIsolate(); | 3761 Dart_ShutdownIsolate(); |
3765 } | 3762 } |
3766 | 3763 |
3767 | 3764 |
3768 TEST_CASE(TypeGetNonParamtericTypes) { | 3765 TEST_CASE(TypeGetNonParamtericTypes) { |
3769 const char* kScriptChars = | 3766 const char* kScriptChars = |
3770 "class MyClass0 {\n" | 3767 "class MyClass0 {\n" |
3771 "}\n" | 3768 "}\n" |
3772 "\n" | 3769 "\n" |
(...skipping 3447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7220 Dart_CObject* response = | 7217 Dart_CObject* response = |
7221 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); | 7218 reinterpret_cast<Dart_CObject*>(Dart_ScopeAllocate(sizeof(Dart_CObject))); |
7222 response->type = Dart_CObject_kInt32; | 7219 response->type = Dart_CObject_kInt32; |
7223 response->value.as_int32 = 321; | 7220 response->value.as_int32 = 321; |
7224 Dart_PostCObject( | 7221 Dart_PostCObject( |
7225 message->value.as_array.values[0]->value.as_send_port.id, response); | 7222 message->value.as_array.values[0]->value.as_send_port.id, response); |
7226 } | 7223 } |
7227 | 7224 |
7228 | 7225 |
7229 TEST_CASE(IllegalNewSendPort) { | 7226 TEST_CASE(IllegalNewSendPort) { |
7230 Dart_Handle error = Dart_NewSendPort(DART_ILLEGAL_PORT); | 7227 Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT); |
7231 EXPECT(Dart_IsError(error)); | 7228 EXPECT(Dart_IsError(error)); |
7232 EXPECT(Dart_IsApiError(error)); | 7229 EXPECT(Dart_IsApiError(error)); |
7233 } | 7230 } |
7234 | 7231 |
7235 | 7232 |
7236 TEST_CASE(IllegalPost) { | 7233 TEST_CASE(IllegalPost) { |
7237 Dart_Handle message = Dart_True(); | 7234 Dart_Handle message = Dart_True(); |
7238 bool success = Dart_Post(DART_ILLEGAL_PORT, message); | 7235 bool success = Dart_Post(ILLEGAL_PORT, message); |
7239 EXPECT(!success); | 7236 EXPECT(!success); |
7240 } | 7237 } |
7241 | 7238 |
7242 | 7239 |
7243 UNIT_TEST_CASE(NewNativePort) { | 7240 UNIT_TEST_CASE(NewNativePort) { |
7244 // Create a port with a bogus handler. | 7241 // Create a port with a bogus handler. |
7245 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); | 7242 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); |
7246 EXPECT_EQ(DART_ILLEGAL_PORT, error_port); | 7243 EXPECT_EQ(ILLEGAL_PORT, error_port); |
7247 | 7244 |
7248 // Create the port w/o a current isolate, just to make sure that works. | 7245 // Create the port w/o a current isolate, just to make sure that works. |
7249 Dart_Port port_id1 = | 7246 Dart_Port port_id1 = |
7250 Dart_NewNativePort("Port123", NewNativePort_send123, true); | 7247 Dart_NewNativePort("Port123", NewNativePort_send123, true); |
7251 | 7248 |
7252 TestIsolateScope __test_isolate__; | 7249 TestIsolateScope __test_isolate__; |
7253 const char* kScriptChars = | 7250 const char* kScriptChars = |
7254 "import 'dart:isolate';\n" | 7251 "import 'dart:isolate';\n" |
7255 "void callPort(SendPort port) {\n" | 7252 "void callPort(SendPort port) {\n" |
7256 " var receivePort = new RawReceivePort();\n" | 7253 " var receivePort = new RawReceivePort();\n" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7322 "void main(exc_child, exc_parent) {\n" | 7319 "void main(exc_child, exc_parent) {\n" |
7323 " var receivePort = new RawReceivePort();\n" | 7320 " var receivePort = new RawReceivePort();\n" |
7324 " Isolate.spawn(entry, [exc_child, receivePort.sendPort]);\n" | 7321 " Isolate.spawn(entry, [exc_child, receivePort.sendPort]);\n" |
7325 " receivePort.handler = (message) {\n" | 7322 " receivePort.handler = (message) {\n" |
7326 " receivePort.close();\n" | 7323 " receivePort.close();\n" |
7327 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" | 7324 " if (message != 'hello') throw new Exception('ShouldNotHappen');\n" |
7328 " if (exc_parent) throw new Exception('MakeParentExit');\n" | 7325 " if (exc_parent) throw new Exception('MakeParentExit');\n" |
7329 " };\n" | 7326 " };\n" |
7330 "}\n"; | 7327 "}\n"; |
7331 | 7328 |
7332 if (Dart_CurrentIsolate() != DART_ILLEGAL_ISOLATE) { | 7329 if (Dart_CurrentIsolate() != NULL) { |
7333 Dart_ExitIsolate(); | 7330 Dart_ExitIsolate(); |
7334 } | 7331 } |
7335 Dart_Isolate isolate = TestCase::CreateTestIsolate(script_name); | 7332 Dart_Isolate isolate = TestCase::CreateTestIsolate(script_name); |
7336 ASSERT(isolate != DART_ILLEGAL_ISOLATE); | 7333 ASSERT(isolate != NULL); |
7337 if (Dart_IsServiceIsolate(isolate)) { | 7334 if (Dart_IsServiceIsolate(isolate)) { |
7338 return isolate; | 7335 return isolate; |
7339 } | 7336 } |
7340 Dart_EnterScope(); | 7337 Dart_EnterScope(); |
7341 Dart_Handle url = NewString(TestCase::url()); | 7338 Dart_Handle url = NewString(TestCase::url()); |
7342 Dart_Handle source = NewString(kScriptChars); | 7339 Dart_Handle source = NewString(kScriptChars); |
7343 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 7340 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
7344 EXPECT_VALID(result); | 7341 EXPECT_VALID(result); |
7345 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); | 7342 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); |
7346 EXPECT_VALID(lib); | 7343 EXPECT_VALID(lib); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7472 "}\n"; | 7469 "}\n"; |
7473 | 7470 |
7474 // Tell the other thread that shared_isolate is created. | 7471 // Tell the other thread that shared_isolate is created. |
7475 Dart_Handle lib; | 7472 Dart_Handle lib; |
7476 { | 7473 { |
7477 MonitorLocker ml(sync); | 7474 MonitorLocker ml(sync); |
7478 char* error = NULL; | 7475 char* error = NULL; |
7479 shared_isolate = Dart_CreateIsolate(NULL, NULL, | 7476 shared_isolate = Dart_CreateIsolate(NULL, NULL, |
7480 bin::isolate_snapshot_buffer, | 7477 bin::isolate_snapshot_buffer, |
7481 NULL, &error); | 7478 NULL, &error); |
7482 EXPECT(shared_isolate != DART_ILLEGAL_ISOLATE); | 7479 EXPECT(shared_isolate != NULL); |
7483 Dart_EnterScope(); | 7480 Dart_EnterScope(); |
7484 Dart_Handle url = NewString(TestCase::url()); | 7481 Dart_Handle url = NewString(TestCase::url()); |
7485 Dart_Handle source = NewString(kScriptChars); | 7482 Dart_Handle source = NewString(kScriptChars); |
7486 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 7483 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
7487 EXPECT_VALID(result); | 7484 EXPECT_VALID(result); |
7488 lib = Dart_LoadScript(url, source, 0, 0); | 7485 lib = Dart_LoadScript(url, source, 0, 0); |
7489 EXPECT_VALID(lib); | 7486 EXPECT_VALID(lib); |
7490 result = Dart_FinalizeLoading(false); | 7487 result = Dart_FinalizeLoading(false); |
7491 EXPECT_VALID(result); | 7488 EXPECT_VALID(result); |
7492 result = | 7489 result = |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7551 EXPECT_EQ(0, result); | 7548 EXPECT_EQ(0, result); |
7552 | 7549 |
7553 { | 7550 { |
7554 MonitorLocker ml(sync); | 7551 MonitorLocker ml(sync); |
7555 // Wait for the other isolate to enter main. | 7552 // Wait for the other isolate to enter main. |
7556 while (!main_entered) { | 7553 while (!main_entered) { |
7557 ml.Wait(); | 7554 ml.Wait(); |
7558 } | 7555 } |
7559 } | 7556 } |
7560 | 7557 |
7561 // Test that Dart_InterruptIsolate returns false when passed an illegal | |
7562 // isolate. | |
7563 EXPECT(!Dart_InterruptIsolate(DART_ILLEGAL_ISOLATE)); | |
7564 | |
7565 // Send a number of interrupts to the other isolate. All but the | 7558 // Send a number of interrupts to the other isolate. All but the |
7566 // last allow execution to continue. The last causes an exception in | 7559 // last allow execution to continue. The last causes an exception in |
7567 // the isolate. | 7560 // the isolate. |
7568 for (int i = 0; i < kInterruptCount; i++) { | 7561 for (int i = 0; i < kInterruptCount; i++) { |
7569 // Space out the interrupts a bit. | 7562 // Space out the interrupts a bit. |
7570 OS::Sleep(i + 1); | 7563 OS::Sleep(i + 1); |
7571 Dart_InterruptIsolate(shared_isolate); | 7564 Dart_InterruptIsolate(shared_isolate); |
7572 { | 7565 { |
7573 MonitorLocker ml(sync); | 7566 MonitorLocker ml(sync); |
7574 // Wait for interrupt_count to be increased. | 7567 // Wait for interrupt_count to be increased. |
7575 while (interrupt_count == i) { | 7568 while (interrupt_count == i) { |
7576 ml.Wait(); | 7569 ml.Wait(); |
7577 } | 7570 } |
7578 OS::Print(" ========== Interrupt processed #%d\n", interrupt_count); | 7571 OS::Print(" ========== Interrupt processed #%d\n", interrupt_count); |
7579 } | 7572 } |
7580 } | 7573 } |
7581 | 7574 |
7582 { | 7575 { |
7583 MonitorLocker ml(sync); | 7576 MonitorLocker ml(sync); |
7584 // Wait for our isolate to finish. | 7577 // Wait for our isolate to finish. |
7585 while (shared_isolate != DART_ILLEGAL_ISOLATE) { | 7578 while (shared_isolate != NULL) { |
7586 ml.Wait(); | 7579 ml.Wait(); |
7587 } | 7580 } |
7588 } | 7581 } |
7589 | 7582 |
7590 // We should have received the expected number of interrupts. | 7583 // We should have received the expected number of interrupts. |
7591 EXPECT_EQ(kInterruptCount, interrupt_count); | 7584 EXPECT_EQ(kInterruptCount, interrupt_count); |
7592 | 7585 |
7593 Isolate::SetInterruptCallback(saved); | 7586 Isolate::SetInterruptCallback(saved); |
7594 } | 7587 } |
7595 | 7588 |
7596 static void* saved_callback_data; | 7589 static void* saved_callback_data; |
7597 static void IsolateShutdownTestCallback(void* callback_data) { | 7590 static void IsolateShutdownTestCallback(void* callback_data) { |
7598 saved_callback_data = callback_data; | 7591 saved_callback_data = callback_data; |
7599 } | 7592 } |
7600 | 7593 |
7601 UNIT_TEST_CASE(IsolateShutdown) { | 7594 UNIT_TEST_CASE(IsolateShutdown) { |
7602 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); | 7595 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); |
7603 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); | 7596 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); |
7604 | 7597 |
7605 saved_callback_data = NULL; | 7598 saved_callback_data = NULL; |
7606 | 7599 |
7607 void* my_data = reinterpret_cast<void*>(12345); | 7600 void* my_data = reinterpret_cast<void*>(12345); |
7608 | 7601 |
7609 // Create an isolate. | 7602 // Create an isolate. |
7610 char* err; | 7603 char* err; |
7611 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, | 7604 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, |
7612 bin::isolate_snapshot_buffer, | 7605 bin::isolate_snapshot_buffer, |
7613 my_data, &err); | 7606 my_data, &err); |
7614 if (isolate == DART_ILLEGAL_ISOLATE) { | 7607 if (isolate == NULL) { |
7615 OS::Print("Creation of isolate failed '%s'\n", err); | 7608 OS::Print("Creation of isolate failed '%s'\n", err); |
7616 free(err); | 7609 free(err); |
7617 } | 7610 } |
7618 EXPECT(isolate != DART_ILLEGAL_ISOLATE); | 7611 EXPECT(isolate != NULL); |
7619 | 7612 |
7620 // The shutdown callback has not been called. | 7613 // The shutdown callback has not been called. |
7621 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); | 7614 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); |
7622 | 7615 |
7623 // Shutdown the isolate. | 7616 // Shutdown the isolate. |
7624 Dart_ShutdownIsolate(); | 7617 Dart_ShutdownIsolate(); |
7625 | 7618 |
7626 // The shutdown callback has been called. | 7619 // The shutdown callback has been called. |
7627 EXPECT_EQ(12345, reinterpret_cast<intptr_t>(saved_callback_data)); | 7620 EXPECT_EQ(12345, reinterpret_cast<intptr_t>(saved_callback_data)); |
7628 | 7621 |
(...skipping 25 matching lines...) Expand all Loading... |
7654 "\n" | 7647 "\n" |
7655 "void main() {\n" | 7648 "void main() {\n" |
7656 " add(4, 5);\n" | 7649 " add(4, 5);\n" |
7657 "}\n"; | 7650 "}\n"; |
7658 | 7651 |
7659 // Create an isolate. | 7652 // Create an isolate. |
7660 char* err; | 7653 char* err; |
7661 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, | 7654 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, |
7662 bin::isolate_snapshot_buffer, | 7655 bin::isolate_snapshot_buffer, |
7663 NULL, &err); | 7656 NULL, &err); |
7664 if (isolate == DART_ILLEGAL_ISOLATE) { | 7657 if (isolate == NULL) { |
7665 OS::Print("Creation of isolate failed '%s'\n", err); | 7658 OS::Print("Creation of isolate failed '%s'\n", err); |
7666 free(err); | 7659 free(err); |
7667 } | 7660 } |
7668 EXPECT(isolate != DART_ILLEGAL_ISOLATE); | 7661 EXPECT(isolate != NULL); |
7669 | 7662 |
7670 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); | 7663 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); |
7671 | 7664 |
7672 { | 7665 { |
7673 Dart_EnterScope(); | 7666 Dart_EnterScope(); |
7674 Dart_Handle url = NewString(TestCase::url()); | 7667 Dart_Handle url = NewString(TestCase::url()); |
7675 Dart_Handle source = NewString(kScriptChars); | 7668 Dart_Handle source = NewString(kScriptChars); |
7676 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 7669 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
7677 EXPECT_VALID(result); | 7670 EXPECT_VALID(result); |
7678 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); | 7671 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); |
7679 EXPECT_VALID(lib); | 7672 EXPECT_VALID(lib); |
7680 result = Dart_FinalizeLoading(false); | 7673 result = Dart_FinalizeLoading(false); |
7681 EXPECT_VALID(result); | 7674 EXPECT_VALID(result); |
7682 result = Dart_Invoke(lib, NewString("main"), 0, NULL); | 7675 result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
7683 EXPECT_VALID(result); | 7676 EXPECT_VALID(result); |
7684 Dart_ExitScope(); | 7677 Dart_ExitScope(); |
7685 } | 7678 } |
7686 | 7679 |
7687 | 7680 |
7688 // The shutdown callback has not been called. | 7681 // The shutdown callback has not been called. |
7689 EXPECT_EQ(0, add_result); | 7682 EXPECT_EQ(0, add_result); |
7690 | 7683 |
7691 EXPECT(isolate != DART_ILLEGAL_ISOLATE); | 7684 EXPECT(isolate != NULL); |
7692 | 7685 |
7693 // Shutdown the isolate. | 7686 // Shutdown the isolate. |
7694 Dart_ShutdownIsolate(); | 7687 Dart_ShutdownIsolate(); |
7695 | 7688 |
7696 // The shutdown callback has been called and ran Dart code. | 7689 // The shutdown callback has been called and ran Dart code. |
7697 EXPECT_EQ(99, add_result); | 7690 EXPECT_EQ(99, add_result); |
7698 } | 7691 } |
7699 | 7692 |
7700 static int64_t GetValue(Dart_Handle arg) { | 7693 static int64_t GetValue(Dart_Handle arg) { |
7701 EXPECT_VALID(arg); | 7694 EXPECT_VALID(arg); |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9138 result = Dart_Invoke(lib, | 9131 result = Dart_Invoke(lib, |
9139 NewString("testView16"), | 9132 NewString("testView16"), |
9140 1, | 9133 1, |
9141 dart_args); | 9134 dart_args); |
9142 EXPECT_VALID(result); | 9135 EXPECT_VALID(result); |
9143 EXPECT(Dart_IsString(result)); | 9136 EXPECT(Dart_IsString(result)); |
9144 } | 9137 } |
9145 } | 9138 } |
9146 | 9139 |
9147 } // namespace dart | 9140 } // namespace dart |
OLD | NEW |