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

Side by Side Diff: vm/dart_api_impl_test.cc

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

Powered by Google App Engine
This is Rietveld 408576698