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 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); | 3612 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); |
3613 Dart_ShutdownIsolate(); | 3613 Dart_ShutdownIsolate(); |
3614 EXPECT(NULL == Dart_CurrentIsolate()); | 3614 EXPECT(NULL == Dart_CurrentIsolate()); |
3615 } | 3615 } |
3616 | 3616 |
3617 | 3617 |
3618 UNIT_TEST_CASE(CurrentIsolateData) { | 3618 UNIT_TEST_CASE(CurrentIsolateData) { |
3619 intptr_t mydata = 12345; | 3619 intptr_t mydata = 12345; |
3620 char* err; | 3620 char* err; |
3621 Dart_Isolate isolate = | 3621 Dart_Isolate isolate = |
3622 Dart_CreateIsolate(NULL, NULL, bin::snapshot_buffer, | 3622 Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer, |
3623 reinterpret_cast<void*>(mydata), | 3623 reinterpret_cast<void*>(mydata), |
3624 &err); | 3624 &err); |
3625 EXPECT(isolate != NULL); | 3625 EXPECT(isolate != NULL); |
3626 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); | 3626 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); |
3627 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); | 3627 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); |
3628 Dart_ShutdownIsolate(); | 3628 Dart_ShutdownIsolate(); |
3629 } | 3629 } |
3630 | 3630 |
3631 | 3631 |
3632 TEST_CASE(IsolateSetCheckedMode) { | 3632 TEST_CASE(IsolateSetCheckedMode) { |
(...skipping 3738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7371 " while (true) {\n" // Infinite empty loop. | 7371 " while (true) {\n" // Infinite empty loop. |
7372 " }\n" | 7372 " }\n" |
7373 "}\n"; | 7373 "}\n"; |
7374 | 7374 |
7375 // Tell the other thread that shared_isolate is created. | 7375 // Tell the other thread that shared_isolate is created. |
7376 Dart_Handle lib; | 7376 Dart_Handle lib; |
7377 { | 7377 { |
7378 MonitorLocker ml(sync); | 7378 MonitorLocker ml(sync); |
7379 char* error = NULL; | 7379 char* error = NULL; |
7380 shared_isolate = Dart_CreateIsolate(NULL, NULL, | 7380 shared_isolate = Dart_CreateIsolate(NULL, NULL, |
7381 bin::snapshot_buffer, | 7381 bin::isolate_snapshot_buffer, |
7382 NULL, &error); | 7382 NULL, &error); |
7383 EXPECT(shared_isolate != NULL); | 7383 EXPECT(shared_isolate != NULL); |
7384 Dart_EnterScope(); | 7384 Dart_EnterScope(); |
7385 Dart_Handle url = NewString(TestCase::url()); | 7385 Dart_Handle url = NewString(TestCase::url()); |
7386 Dart_Handle source = NewString(kScriptChars); | 7386 Dart_Handle source = NewString(kScriptChars); |
7387 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 7387 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); |
7388 EXPECT_VALID(result); | 7388 EXPECT_VALID(result); |
7389 lib = Dart_LoadScript(url, source, 0, 0); | 7389 lib = Dart_LoadScript(url, source, 0, 0); |
7390 EXPECT_VALID(lib); | 7390 EXPECT_VALID(lib); |
7391 result = Dart_FinalizeLoading(false); | 7391 result = Dart_FinalizeLoading(false); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7499 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); | 7499 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); |
7500 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); | 7500 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); |
7501 | 7501 |
7502 saved_callback_data = NULL; | 7502 saved_callback_data = NULL; |
7503 | 7503 |
7504 void* my_data = reinterpret_cast<void*>(12345); | 7504 void* my_data = reinterpret_cast<void*>(12345); |
7505 | 7505 |
7506 // Create an isolate. | 7506 // Create an isolate. |
7507 char* err; | 7507 char* err; |
7508 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, | 7508 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, |
7509 bin::snapshot_buffer, | 7509 bin::isolate_snapshot_buffer, |
7510 my_data, &err); | 7510 my_data, &err); |
7511 if (isolate == NULL) { | 7511 if (isolate == NULL) { |
7512 OS::Print("Creation of isolate failed '%s'\n", err); | 7512 OS::Print("Creation of isolate failed '%s'\n", err); |
7513 free(err); | 7513 free(err); |
7514 } | 7514 } |
7515 EXPECT(isolate != NULL); | 7515 EXPECT(isolate != NULL); |
7516 | 7516 |
7517 // The shutdown callback has not been called. | 7517 // The shutdown callback has not been called. |
7518 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); | 7518 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); |
7519 | 7519 |
(...skipping 29 matching lines...) Expand all Loading... |
7549 " return a + b;\n" | 7549 " return a + b;\n" |
7550 "}\n" | 7550 "}\n" |
7551 "\n" | 7551 "\n" |
7552 "void main() {\n" | 7552 "void main() {\n" |
7553 " add(4, 5);\n" | 7553 " add(4, 5);\n" |
7554 "}\n"; | 7554 "}\n"; |
7555 | 7555 |
7556 // Create an isolate. | 7556 // Create an isolate. |
7557 char* err; | 7557 char* err; |
7558 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, | 7558 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, |
7559 bin::snapshot_buffer, | 7559 bin::isolate_snapshot_buffer, |
7560 NULL, &err); | 7560 NULL, &err); |
7561 if (isolate == NULL) { | 7561 if (isolate == NULL) { |
7562 OS::Print("Creation of isolate failed '%s'\n", err); | 7562 OS::Print("Creation of isolate failed '%s'\n", err); |
7563 free(err); | 7563 free(err); |
7564 } | 7564 } |
7565 EXPECT(isolate != NULL); | 7565 EXPECT(isolate != NULL); |
7566 | 7566 |
7567 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); | 7567 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); |
7568 | 7568 |
7569 { | 7569 { |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8922 result = Dart_Invoke(lib, | 8922 result = Dart_Invoke(lib, |
8923 NewString("testView16"), | 8923 NewString("testView16"), |
8924 1, | 8924 1, |
8925 dart_args); | 8925 dart_args); |
8926 EXPECT_VALID(result); | 8926 EXPECT_VALID(result); |
8927 EXPECT(Dart_IsString(result)); | 8927 EXPECT(Dart_IsString(result)); |
8928 } | 8928 } |
8929 } | 8929 } |
8930 | 8930 |
8931 } // namespace dart | 8931 } // namespace dart |
OLD | NEW |