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