| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 3579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3590 const char* kScriptChars = | 3590 const char* kScriptChars = |
| 3591 "main() {" | 3591 "main() {" |
| 3592 " return 12345;" | 3592 " return 12345;" |
| 3593 "}"; | 3593 "}"; |
| 3594 Dart_Handle url = Dart_NewString(TestCase::url()); | 3594 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3595 Dart_Handle source = Dart_NewString(kScriptChars); | 3595 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3596 Dart_Handle error = Dart_Error("incoming error"); | 3596 Dart_Handle error = Dart_Error("incoming error"); |
| 3597 Dart_Handle result; | 3597 Dart_Handle result; |
| 3598 Dart_Handle import_map = Dart_NewList(0); | 3598 Dart_Handle import_map = Dart_NewList(0); |
| 3599 | 3599 |
| 3600 result = Dart_SetLibraryTagHandler(library_handler); | 3600 result = Dart_LoadScript(Dart_Null(), source, library_handler, import_map); |
| 3601 EXPECT_VALID(result); | |
| 3602 | |
| 3603 result = Dart_LoadScript(Dart_Null(), source, import_map); | |
| 3604 EXPECT(Dart_IsError(result)); | 3601 EXPECT(Dart_IsError(result)); |
| 3605 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", | 3602 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", |
| 3606 Dart_GetError(result)); | 3603 Dart_GetError(result)); |
| 3607 | 3604 |
| 3608 result = Dart_LoadScript(Dart_True(), source, import_map); | 3605 result = Dart_LoadScript(Dart_True(), source, library_handler, import_map); |
| 3609 EXPECT(Dart_IsError(result)); | 3606 EXPECT(Dart_IsError(result)); |
| 3610 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.", | 3607 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.", |
| 3611 Dart_GetError(result)); | 3608 Dart_GetError(result)); |
| 3612 | 3609 |
| 3613 result = Dart_LoadScript(error, source, import_map); | 3610 result = Dart_LoadScript(error, source, library_handler, import_map); |
| 3614 EXPECT(Dart_IsError(result)); | 3611 EXPECT(Dart_IsError(result)); |
| 3615 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 3612 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 3616 | 3613 |
| 3617 result = Dart_LoadScript(url, Dart_Null(), import_map); | 3614 result = Dart_LoadScript(url, Dart_Null(), library_handler, import_map); |
| 3618 EXPECT(Dart_IsError(result)); | 3615 EXPECT(Dart_IsError(result)); |
| 3619 EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.", | 3616 EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.", |
| 3620 Dart_GetError(result)); | 3617 Dart_GetError(result)); |
| 3621 | 3618 |
| 3622 result = Dart_LoadScript(url, Dart_True(), import_map); | 3619 result = Dart_LoadScript(url, Dart_True(), library_handler, import_map); |
| 3623 EXPECT(Dart_IsError(result)); | 3620 EXPECT(Dart_IsError(result)); |
| 3624 EXPECT_STREQ( | 3621 EXPECT_STREQ( |
| 3625 "Dart_LoadScript expects argument 'source' to be of type String.", | 3622 "Dart_LoadScript expects argument 'source' to be of type String.", |
| 3626 Dart_GetError(result)); | 3623 Dart_GetError(result)); |
| 3627 | 3624 |
| 3628 result = Dart_LoadScript(url, error, import_map); | 3625 result = Dart_LoadScript(url, error, library_handler, import_map); |
| 3629 EXPECT(Dart_IsError(result)); | 3626 EXPECT(Dart_IsError(result)); |
| 3630 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 3627 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 3631 | 3628 |
| 3632 // Load a script successfully. | 3629 // Load a script successfully. |
| 3633 result = Dart_LoadScript(url, source, import_map); | 3630 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 3634 EXPECT_VALID(result); | 3631 EXPECT_VALID(result); |
| 3635 | 3632 |
| 3636 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); | 3633 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); |
| 3637 EXPECT_VALID(result); | 3634 EXPECT_VALID(result); |
| 3638 EXPECT(Dart_IsInteger(result)); | 3635 EXPECT(Dart_IsInteger(result)); |
| 3639 int64_t value = 0; | 3636 int64_t value = 0; |
| 3640 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); | 3637 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 3641 EXPECT_EQ(12345, value); | 3638 EXPECT_EQ(12345, value); |
| 3642 | 3639 |
| 3643 // Further calls to LoadScript are errors. | 3640 // Further calls to LoadScript are errors. |
| 3644 result = Dart_LoadScript(url, source, import_map); | 3641 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 3645 EXPECT(Dart_IsError(result)); | 3642 EXPECT(Dart_IsError(result)); |
| 3646 EXPECT_STREQ("Dart_LoadScript: " | 3643 EXPECT_STREQ("Dart_LoadScript: " |
| 3647 "A script has already been loaded from 'dart:test-lib'.", | 3644 "A script has already been loaded from 'dart:test-lib'.", |
| 3648 Dart_GetError(result)); | 3645 Dart_GetError(result)); |
| 3649 } | 3646 } |
| 3650 | 3647 |
| 3651 | 3648 |
| 3652 static const char* var_mapping[] = { | 3649 static const char* var_mapping[] = { |
| 3653 "GOOGLE3", ".", | 3650 "GOOGLE3", ".", |
| 3654 "ABC", "lala", | 3651 "ABC", "lala", |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 "main() {" | 3700 "main() {" |
| 3704 " return 12345;" | 3701 " return 12345;" |
| 3705 "}"; | 3702 "}"; |
| 3706 Dart_Handle url = Dart_NewString(TestCase::url()); | 3703 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3707 Dart_Handle source = Dart_NewString(kScriptChars); | 3704 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3708 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); | 3705 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); |
| 3709 Dart_Handle import_map = Dart_NewList(length); | 3706 Dart_Handle import_map = Dart_NewList(length); |
| 3710 for (intptr_t i = 0; i < length; i++) { | 3707 for (intptr_t i = 0; i < length; i++) { |
| 3711 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); | 3708 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); |
| 3712 } | 3709 } |
| 3713 Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler); | 3710 Dart_Handle result = Dart_LoadScript(url, |
| 3714 EXPECT_VALID(result); | 3711 source, |
| 3715 result = Dart_LoadScript(url, source, import_map); | 3712 import_library_handler, |
| 3713 import_map); |
| 3716 EXPECT(!Dart_IsError(result)); | 3714 EXPECT(!Dart_IsError(result)); |
| 3717 } | 3715 } |
| 3718 | 3716 |
| 3719 | 3717 |
| 3720 TEST_CASE(LoadImportScriptError1) { | 3718 TEST_CASE(LoadImportScriptError1) { |
| 3721 const char* kScriptChars = | 3719 const char* kScriptChars = |
| 3722 "#import('abc${DEF}def/extra_weird.dart');" | 3720 "#import('abc${DEF}def/extra_weird.dart');" |
| 3723 "main() {" | 3721 "main() {" |
| 3724 " return 12345;" | 3722 " return 12345;" |
| 3725 "}"; | 3723 "}"; |
| 3726 Dart_Handle url = Dart_NewString(TestCase::url()); | 3724 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3727 Dart_Handle source = Dart_NewString(kScriptChars); | 3725 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3728 Dart_Handle import_map = Dart_NewList(0); | 3726 Dart_Handle import_map = Dart_NewList(0); |
| 3729 Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler); | 3727 Dart_Handle result = Dart_LoadScript(url, |
| 3730 EXPECT_VALID(result); | 3728 source, |
| 3731 result = Dart_LoadScript(url, source, import_map); | 3729 import_library_handler, |
| 3730 import_map); |
| 3732 EXPECT(Dart_IsError(result)); | 3731 EXPECT(Dart_IsError(result)); |
| 3733 EXPECT(strstr(Dart_GetError(result), | 3732 EXPECT(strstr(Dart_GetError(result), |
| 3734 "import variable 'DEF' has not been defined")); | 3733 "import variable 'DEF' has not been defined")); |
| 3735 } | 3734 } |
| 3736 | 3735 |
| 3737 | 3736 |
| 3738 TEST_CASE(LoadImportScriptError2) { | 3737 TEST_CASE(LoadImportScriptError2) { |
| 3739 const char* kScriptChars = | 3738 const char* kScriptChars = |
| 3740 "#import('abc${ABC/extra_weird.dart');" | 3739 "#import('abc${ABC/extra_weird.dart');" |
| 3741 "main() {" | 3740 "main() {" |
| 3742 " return 12345;" | 3741 " return 12345;" |
| 3743 "}"; | 3742 "}"; |
| 3744 Dart_Handle url = Dart_NewString(TestCase::url()); | 3743 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3745 Dart_Handle source = Dart_NewString(kScriptChars); | 3744 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3746 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); | 3745 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); |
| 3747 Dart_Handle import_map = Dart_NewList(length); | 3746 Dart_Handle import_map = Dart_NewList(length); |
| 3748 for (intptr_t i = 0; i < length; i++) { | 3747 for (intptr_t i = 0; i < length; i++) { |
| 3749 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); | 3748 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); |
| 3750 } | 3749 } |
| 3751 Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler); | 3750 Dart_Handle result = Dart_LoadScript(url, |
| 3752 EXPECT_VALID(result); | 3751 source, |
| 3753 result = Dart_LoadScript(url, source, import_map); | 3752 import_library_handler, |
| 3753 import_map); |
| 3754 EXPECT(Dart_IsError(result)); | 3754 EXPECT(Dart_IsError(result)); |
| 3755 EXPECT(strstr(Dart_GetError(result), "'}' expected")); | 3755 EXPECT(strstr(Dart_GetError(result), "'}' expected")); |
| 3756 } | 3756 } |
| 3757 | 3757 |
| 3758 | 3758 |
| 3759 TEST_CASE(LoadScript_CompileError) { | 3759 TEST_CASE(LoadScript_CompileError) { |
| 3760 const char* kScriptChars = | 3760 const char* kScriptChars = |
| 3761 ")"; | 3761 ")"; |
| 3762 Dart_Handle url = Dart_NewString(TestCase::url()); | 3762 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3763 Dart_Handle source = Dart_NewString(kScriptChars); | 3763 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3764 Dart_Handle import_map = Dart_NewList(0); | 3764 Dart_Handle import_map = Dart_NewList(0); |
| 3765 Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler); | 3765 Dart_Handle result = Dart_LoadScript(url, |
| 3766 EXPECT_VALID(result); | 3766 source, |
| 3767 result = Dart_LoadScript(url, source, import_map); | 3767 library_handler, |
| 3768 import_map); |
| 3768 EXPECT(Dart_IsError(result)); | 3769 EXPECT(Dart_IsError(result)); |
| 3769 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); | 3770 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); |
| 3770 } | 3771 } |
| 3771 | 3772 |
| 3772 | 3773 |
| 3773 TEST_CASE(LookupLibrary) { | 3774 TEST_CASE(LookupLibrary) { |
| 3774 const char* kScriptChars = | 3775 const char* kScriptChars = |
| 3775 "#import('library1.dart');" | 3776 "#import('library1.dart');" |
| 3776 "main() {}"; | 3777 "main() {}"; |
| 3777 const char* kLibrary1Chars = | 3778 const char* kLibrary1Chars = |
| 3778 "#library('library1.dart');" | 3779 "#library('library1.dart');" |
| 3779 "#import('library2.dart');"; | 3780 "#import('library2.dart');"; |
| 3780 | 3781 |
| 3781 // Create a test library and Load up a test script in it. | 3782 // Create a test library and Load up a test script in it. |
| 3782 Dart_Handle url = Dart_NewString(TestCase::url()); | 3783 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3783 Dart_Handle source = Dart_NewString(kScriptChars); | 3784 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3784 Dart_Handle import_map = Dart_NewList(0); | 3785 Dart_Handle import_map = Dart_NewList(0); |
| 3785 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler); | 3786 Dart_Handle result = Dart_LoadScript(url, |
| 3786 EXPECT_VALID(result); | 3787 source, |
| 3787 result = Dart_LoadScript(url, source, import_map); | 3788 library_handler, |
| 3789 import_map); |
| 3788 EXPECT_VALID(result); | 3790 EXPECT_VALID(result); |
| 3789 | 3791 |
| 3790 url = Dart_NewString("library1.dart"); | 3792 url = Dart_NewString("library1.dart"); |
| 3791 source = Dart_NewString(kLibrary1Chars); | 3793 source = Dart_NewString(kLibrary1Chars); |
| 3792 result = Dart_LoadLibrary(url, source, import_map); | 3794 result = Dart_LoadLibrary(url, source, import_map); |
| 3793 EXPECT_VALID(result); | 3795 EXPECT_VALID(result); |
| 3794 | 3796 |
| 3795 result = Dart_LookupLibrary(url); | 3797 result = Dart_LookupLibrary(url); |
| 3796 EXPECT_VALID(result); | 3798 EXPECT_VALID(result); |
| 3797 | 3799 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 " static bar() native \"SomeNativeFunction2\";" | 4097 " static bar() native \"SomeNativeFunction2\";" |
| 4096 " static baz() native \"SomeNativeFunction3\";" | 4098 " static baz() native \"SomeNativeFunction3\";" |
| 4097 "}"; | 4099 "}"; |
| 4098 Dart_Handle error = Dart_Error("incoming error"); | 4100 Dart_Handle error = Dart_Error("incoming error"); |
| 4099 Dart_Handle result; | 4101 Dart_Handle result; |
| 4100 | 4102 |
| 4101 // Load a test script. | 4103 // Load a test script. |
| 4102 Dart_Handle url = Dart_NewString(TestCase::url()); | 4104 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4103 Dart_Handle source = Dart_NewString(kScriptChars); | 4105 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4104 Dart_Handle import_map = Dart_NewList(0); | 4106 Dart_Handle import_map = Dart_NewList(0); |
| 4105 result = Dart_SetLibraryTagHandler(library_handler); | 4107 Dart_Handle lib = Dart_LoadScript(url, source, library_handler, import_map); |
| 4106 EXPECT_VALID(result); | |
| 4107 Dart_Handle lib = Dart_LoadScript(url, source, import_map); | |
| 4108 EXPECT_VALID(lib); | 4108 EXPECT_VALID(lib); |
| 4109 EXPECT(Dart_IsLibrary(lib)); | 4109 EXPECT(Dart_IsLibrary(lib)); |
| 4110 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Test")); | 4110 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Test")); |
| 4111 EXPECT_VALID(cls); | 4111 EXPECT_VALID(cls); |
| 4112 | 4112 |
| 4113 result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1); | 4113 result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1); |
| 4114 EXPECT(Dart_IsError(result)); | 4114 EXPECT(Dart_IsError(result)); |
| 4115 EXPECT_STREQ( | 4115 EXPECT_STREQ( |
| 4116 "Dart_SetNativeResolver expects argument 'library' to be non-null.", | 4116 "Dart_SetNativeResolver expects argument 'library' to be non-null.", |
| 4117 Dart_GetError(result)); | 4117 Dart_GetError(result)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4176 "#library('library1.dart');" | 4176 "#library('library1.dart');" |
| 4177 "#import('library2.dart');" | 4177 "#import('library2.dart');" |
| 4178 "var foo1;"; | 4178 "var foo1;"; |
| 4179 const char* kLibrary2Chars = | 4179 const char* kLibrary2Chars = |
| 4180 "#library('library2.dart');" | 4180 "#library('library2.dart');" |
| 4181 "var foo;"; | 4181 "var foo;"; |
| 4182 Dart_Handle result; | 4182 Dart_Handle result; |
| 4183 // Create a test library and Load up a test script in it. | 4183 // Create a test library and Load up a test script in it. |
| 4184 Dart_Handle url = Dart_NewString(TestCase::url()); | 4184 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4185 Dart_Handle source = Dart_NewString(kScriptChars); | 4185 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4186 result = Dart_SetLibraryTagHandler(library_handler); | 4186 result = Dart_LoadScript(url, source, library_handler, Dart_Null()); |
| 4187 EXPECT_VALID(result); | |
| 4188 result = Dart_LoadScript(url, source, Dart_Null()); | |
| 4189 | 4187 |
| 4190 url = Dart_NewString("library1.dart"); | 4188 url = Dart_NewString("library1.dart"); |
| 4191 source = Dart_NewString(kLibrary1Chars); | 4189 source = Dart_NewString(kLibrary1Chars); |
| 4192 Dart_LoadLibrary(url, source, Dart_Null()); | 4190 Dart_LoadLibrary(url, source, Dart_Null()); |
| 4193 | 4191 |
| 4194 url = Dart_NewString("library2.dart"); | 4192 url = Dart_NewString("library2.dart"); |
| 4195 source = Dart_NewString(kLibrary2Chars); | 4193 source = Dart_NewString(kLibrary2Chars); |
| 4196 Dart_LoadLibrary(url, source, Dart_Null()); | 4194 Dart_LoadLibrary(url, source, Dart_Null()); |
| 4197 | 4195 |
| 4198 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); | 4196 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4214 "var foo1;"; | 4212 "var foo1;"; |
| 4215 const char* kLibrary2Chars = | 4213 const char* kLibrary2Chars = |
| 4216 "#library('library2.dart');" | 4214 "#library('library2.dart');" |
| 4217 "#import('library1.dart');" | 4215 "#import('library1.dart');" |
| 4218 "var foo;"; | 4216 "var foo;"; |
| 4219 Dart_Handle result; | 4217 Dart_Handle result; |
| 4220 // Create a test library and Load up a test script in it. | 4218 // Create a test library and Load up a test script in it. |
| 4221 Dart_Handle url = Dart_NewString(TestCase::url()); | 4219 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4222 Dart_Handle source = Dart_NewString(kScriptChars); | 4220 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4223 Dart_Handle import_map = Dart_NewList(0); | 4221 Dart_Handle import_map = Dart_NewList(0); |
| 4224 result = Dart_SetLibraryTagHandler(library_handler); | 4222 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 4225 EXPECT_VALID(result); | |
| 4226 result = Dart_LoadScript(url, source, import_map); | |
| 4227 | 4223 |
| 4228 url = Dart_NewString("library1.dart"); | 4224 url = Dart_NewString("library1.dart"); |
| 4229 source = Dart_NewString(kLibrary1Chars); | 4225 source = Dart_NewString(kLibrary1Chars); |
| 4230 Dart_LoadLibrary(url, source, import_map); | 4226 Dart_LoadLibrary(url, source, import_map); |
| 4231 | 4227 |
| 4232 url = Dart_NewString("library2.dart"); | 4228 url = Dart_NewString("library2.dart"); |
| 4233 source = Dart_NewString(kLibrary2Chars); | 4229 source = Dart_NewString(kLibrary2Chars); |
| 4234 Dart_LoadLibrary(url, source, import_map); | 4230 Dart_LoadLibrary(url, source, import_map); |
| 4235 | 4231 |
| 4236 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); | 4232 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4249 "var foo;"; | 4245 "var foo;"; |
| 4250 const char* kLibrary2Chars = | 4246 const char* kLibrary2Chars = |
| 4251 "#library('library2.dart');" | 4247 "#library('library2.dart');" |
| 4252 "var foo;"; | 4248 "var foo;"; |
| 4253 Dart_Handle result; | 4249 Dart_Handle result; |
| 4254 | 4250 |
| 4255 // Create a test library and Load up a test script in it. | 4251 // Create a test library and Load up a test script in it. |
| 4256 Dart_Handle url = Dart_NewString(TestCase::url()); | 4252 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4257 Dart_Handle source = Dart_NewString(kScriptChars); | 4253 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4258 Dart_Handle import_map = Dart_NewList(0); | 4254 Dart_Handle import_map = Dart_NewList(0); |
| 4259 result = Dart_SetLibraryTagHandler(library_handler); | 4255 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 4260 EXPECT_VALID(result); | |
| 4261 result = Dart_LoadScript(url, source, import_map); | |
| 4262 | 4256 |
| 4263 url = Dart_NewString("library2.dart"); | 4257 url = Dart_NewString("library2.dart"); |
| 4264 source = Dart_NewString(kLibrary2Chars); | 4258 source = Dart_NewString(kLibrary2Chars); |
| 4265 Dart_LoadLibrary(url, source, import_map); | 4259 Dart_LoadLibrary(url, source, import_map); |
| 4266 | 4260 |
| 4267 url = Dart_NewString("library1.dart"); | 4261 url = Dart_NewString("library1.dart"); |
| 4268 source = Dart_NewString(kLibrary1Chars); | 4262 source = Dart_NewString(kLibrary1Chars); |
| 4269 Dart_LoadLibrary(url, source, import_map); | 4263 Dart_LoadLibrary(url, source, import_map); |
| 4270 | 4264 |
| 4271 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); | 4265 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4306 "var fooE = 10; //fooC has duplicate def. so should be an error."; | 4300 "var fooE = 10; //fooC has duplicate def. so should be an error."; |
| 4307 const char* kLibraryFChars = | 4301 const char* kLibraryFChars = |
| 4308 "#library('libraryF.dart');" | 4302 "#library('libraryF.dart');" |
| 4309 "var fooC;"; | 4303 "var fooC;"; |
| 4310 Dart_Handle result; | 4304 Dart_Handle result; |
| 4311 | 4305 |
| 4312 // Create a test library and Load up a test script in it. | 4306 // Create a test library and Load up a test script in it. |
| 4313 Dart_Handle url = Dart_NewString(TestCase::url()); | 4307 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4314 Dart_Handle source = Dart_NewString(kScriptChars); | 4308 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4315 Dart_Handle import_map = Dart_NewList(0); | 4309 Dart_Handle import_map = Dart_NewList(0); |
| 4316 result = Dart_SetLibraryTagHandler(library_handler); | 4310 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 4317 EXPECT_VALID(result); | |
| 4318 result = Dart_LoadScript(url, source, import_map); | |
| 4319 | 4311 |
| 4320 url = Dart_NewString("libraryA.dart"); | 4312 url = Dart_NewString("libraryA.dart"); |
| 4321 source = Dart_NewString(kLibraryAChars); | 4313 source = Dart_NewString(kLibraryAChars); |
| 4322 Dart_LoadLibrary(url, source, import_map); | 4314 Dart_LoadLibrary(url, source, import_map); |
| 4323 | 4315 |
| 4324 url = Dart_NewString("libraryC.dart"); | 4316 url = Dart_NewString("libraryC.dart"); |
| 4325 source = Dart_NewString(kLibraryCChars); | 4317 source = Dart_NewString(kLibraryCChars); |
| 4326 Dart_LoadLibrary(url, source, import_map); | 4318 Dart_LoadLibrary(url, source, import_map); |
| 4327 | 4319 |
| 4328 url = Dart_NewString("libraryB.dart"); | 4320 url = Dart_NewString("libraryB.dart"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4360 "#library('lib.dart');" | 4352 "#library('lib.dart');" |
| 4361 "interface X {" | 4353 "interface X {" |
| 4362 " void set handler(void callback(List<int> x));" | 4354 " void set handler(void callback(List<int> x));" |
| 4363 "}"; | 4355 "}"; |
| 4364 Dart_Handle result; | 4356 Dart_Handle result; |
| 4365 | 4357 |
| 4366 // Create a test library and Load up a test script in it. | 4358 // Create a test library and Load up a test script in it. |
| 4367 Dart_Handle url = Dart_NewString(TestCase::url()); | 4359 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4368 Dart_Handle source = Dart_NewString(kScriptChars); | 4360 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4369 Dart_Handle import_map = Dart_NewList(0); | 4361 Dart_Handle import_map = Dart_NewList(0); |
| 4370 result = Dart_SetLibraryTagHandler(library_handler); | 4362 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 4371 EXPECT_VALID(result); | |
| 4372 result = Dart_LoadScript(url, source, import_map); | |
| 4373 | 4363 |
| 4374 url = Dart_NewString("lib.dart"); | 4364 url = Dart_NewString("lib.dart"); |
| 4375 source = Dart_NewString(kLibraryChars); | 4365 source = Dart_NewString(kLibraryChars); |
| 4376 Dart_LoadLibrary(url, source, import_map); | 4366 Dart_LoadLibrary(url, source, import_map); |
| 4377 | 4367 |
| 4378 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); | 4368 result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL); |
| 4379 EXPECT_VALID(result); | 4369 EXPECT_VALID(result); |
| 4380 } | 4370 } |
| 4381 | 4371 |
| 4382 | 4372 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4499 | 4489 |
| 4500 if (Dart_CurrentIsolate() != NULL) { | 4490 if (Dart_CurrentIsolate() != NULL) { |
| 4501 Dart_ExitIsolate(); | 4491 Dart_ExitIsolate(); |
| 4502 } | 4492 } |
| 4503 Dart_Isolate isolate = TestCase::CreateTestIsolate(); | 4493 Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
| 4504 ASSERT(isolate != NULL); | 4494 ASSERT(isolate != NULL); |
| 4505 Dart_EnterScope(); | 4495 Dart_EnterScope(); |
| 4506 Dart_Handle url = Dart_NewString(TestCase::url()); | 4496 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4507 Dart_Handle source = Dart_NewString(kScriptChars); | 4497 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4508 Dart_Handle import_map = Dart_NewList(0); | 4498 Dart_Handle import_map = Dart_NewList(0); |
| 4509 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 4499 Dart_Handle lib = Dart_LoadScript(url, |
| 4510 EXPECT_VALID(result); | 4500 source, |
| 4511 Dart_Handle lib = Dart_LoadScript(url, source, import_map); | 4501 TestCase::library_handler, |
| 4502 import_map); |
| 4512 EXPECT_VALID(lib); | 4503 EXPECT_VALID(lib); |
| 4513 Dart_ExitScope(); | 4504 Dart_ExitScope(); |
| 4514 return true; | 4505 return true; |
| 4515 } | 4506 } |
| 4516 | 4507 |
| 4517 | 4508 |
| 4518 // Common code for RunLoop_Success/RunLoop_Failure. | 4509 // Common code for RunLoop_Success/RunLoop_Failure. |
| 4519 static void RunLoopTest(bool throw_exception_child, | 4510 static void RunLoopTest(bool throw_exception_child, |
| 4520 bool throw_exception_parent) { | 4511 bool throw_exception_parent) { |
| 4521 Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); | 4512 Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4603 Dart_Handle lib; | 4594 Dart_Handle lib; |
| 4604 { | 4595 { |
| 4605 sync->Enter(); | 4596 sync->Enter(); |
| 4606 char* error = NULL; | 4597 char* error = NULL; |
| 4607 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error); | 4598 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error); |
| 4608 EXPECT(shared_isolate != NULL); | 4599 EXPECT(shared_isolate != NULL); |
| 4609 Dart_EnterScope(); | 4600 Dart_EnterScope(); |
| 4610 Dart_Handle url = Dart_NewString(TestCase::url()); | 4601 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 4611 Dart_Handle source = Dart_NewString(kScriptChars); | 4602 Dart_Handle source = Dart_NewString(kScriptChars); |
| 4612 Dart_Handle import_map = Dart_NewList(0); | 4603 Dart_Handle import_map = Dart_NewList(0); |
| 4613 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); | 4604 lib = Dart_LoadScript(url, source, TestCase::library_handler, import_map); |
| 4614 EXPECT_VALID(result); | |
| 4615 lib = Dart_LoadScript(url, source, import_map); | |
| 4616 EXPECT_VALID(lib); | 4605 EXPECT_VALID(lib); |
| 4617 result = Dart_SetNativeResolver(lib, &IsolateInterruptTestNativeLookup); | 4606 Dart_Handle result = Dart_SetNativeResolver( |
| 4607 lib, &IsolateInterruptTestNativeLookup); |
| 4618 DART_CHECK_VALID(result); | 4608 DART_CHECK_VALID(result); |
| 4619 | 4609 |
| 4620 sync->Notify(); | 4610 sync->Notify(); |
| 4621 sync->Exit(); | 4611 sync->Exit(); |
| 4622 } | 4612 } |
| 4623 | 4613 |
| 4624 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("main"), 0, NULL); | 4614 Dart_Handle result = Dart_Invoke(lib, Dart_NewString("main"), 0, NULL); |
| 4625 EXPECT(Dart_IsError(result)); | 4615 EXPECT(Dart_IsError(result)); |
| 4626 EXPECT(Dart_ErrorHasException(result)); | 4616 EXPECT(Dart_ErrorHasException(result)); |
| 4627 EXPECT_SUBSTRING("Unhandled exception:\nfoo\n", | 4617 EXPECT_SUBSTRING("Unhandled exception:\nfoo\n", |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4711 // We should have received the expected number of interrupts. | 4701 // We should have received the expected number of interrupts. |
| 4712 EXPECT_EQ(kInterruptCount, interrupt_count); | 4702 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 4713 | 4703 |
| 4714 // Give the spawned thread enough time to properly exit. | 4704 // Give the spawned thread enough time to properly exit. |
| 4715 Isolate::SetInterruptCallback(saved); | 4705 Isolate::SetInterruptCallback(saved); |
| 4716 } | 4706 } |
| 4717 | 4707 |
| 4718 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 4708 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 4719 | 4709 |
| 4720 } // namespace dart | 4710 } // namespace dart |
| OLD | NEW |