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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 429013002: Make Dart_LoadLibrary and Dart_LoadSource take line and column offsets like Dart_LoadScript. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 4 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/service.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 "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 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3863 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3864 Dart_Handle type = Dart_GetType(lib, NewString("Fields"), 0, NULL); 3864 Dart_Handle type = Dart_GetType(lib, NewString("Fields"), 0, NULL);
3865 EXPECT_VALID(type); 3865 EXPECT_VALID(type);
3866 Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL); 3866 Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL);
3867 EXPECT_VALID(instance); 3867 EXPECT_VALID(instance);
3868 Dart_Handle name; 3868 Dart_Handle name;
3869 3869
3870 // Load imported lib. 3870 // Load imported lib.
3871 Dart_Handle url = NewString("library_url"); 3871 Dart_Handle url = NewString("library_url");
3872 Dart_Handle source = NewString(kImportedScriptChars); 3872 Dart_Handle source = NewString(kImportedScriptChars);
3873 Dart_Handle imported_lib = Dart_LoadLibrary(url, source); 3873 Dart_Handle imported_lib = Dart_LoadLibrary(url, source, 0, 0);
3874 Dart_Handle prefix = NewString(""); 3874 Dart_Handle prefix = NewString("");
3875 EXPECT_VALID(imported_lib); 3875 EXPECT_VALID(imported_lib);
3876 Dart_Handle result = Dart_LibraryImportLibrary(lib, imported_lib, prefix); 3876 Dart_Handle result = Dart_LibraryImportLibrary(lib, imported_lib, prefix);
3877 EXPECT_VALID(result); 3877 EXPECT_VALID(result);
3878 result = Dart_FinalizeLoading(false); 3878 result = Dart_FinalizeLoading(false);
3879 EXPECT_VALID(result); 3879 EXPECT_VALID(result);
3880 result = Dart_Invoke(imported_lib, NewString("test2"), 0, NULL); 3880 result = Dart_Invoke(imported_lib, NewString("test2"), 0, NULL);
3881 EXPECT_VALID(result); 3881 EXPECT_VALID(result);
3882 3882
3883 // Instance field. 3883 // Instance field.
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
5220 "void local() {}\n" 5220 "void local() {}\n"
5221 "void _local() {}\n"; 5221 "void _local() {}\n";
5222 const char* kLibrary2Chars = 5222 const char* kLibrary2Chars =
5223 "library library2_name;\n" 5223 "library library2_name;\n"
5224 "void imported() {}\n" 5224 "void imported() {}\n"
5225 "void _imported() {}\n"; 5225 "void _imported() {}\n";
5226 5226
5227 // Load lib1 5227 // Load lib1
5228 Dart_Handle url = NewString("library1_url"); 5228 Dart_Handle url = NewString("library1_url");
5229 Dart_Handle source = NewString(kLibrary1Chars); 5229 Dart_Handle source = NewString(kLibrary1Chars);
5230 Dart_Handle lib1 = Dart_LoadLibrary(url, source); 5230 Dart_Handle lib1 = Dart_LoadLibrary(url, source, 0, 0);
5231 EXPECT_VALID(lib1); 5231 EXPECT_VALID(lib1);
5232 5232
5233 // Load lib2 5233 // Load lib2
5234 url = NewString("library2_url"); 5234 url = NewString("library2_url");
5235 source = NewString(kLibrary2Chars); 5235 source = NewString(kLibrary2Chars);
5236 Dart_Handle lib2 = Dart_LoadLibrary(url, source); 5236 Dart_Handle lib2 = Dart_LoadLibrary(url, source, 0, 0);
5237 EXPECT_VALID(lib2); 5237 EXPECT_VALID(lib2);
5238 5238
5239 // Import lib2 from lib1 5239 // Import lib2 from lib1
5240 Dart_Handle result = Dart_LibraryImportLibrary(lib1, lib2, Dart_Null()); 5240 Dart_Handle result = Dart_LibraryImportLibrary(lib1, lib2, Dart_Null());
5241 EXPECT_VALID(result); 5241 EXPECT_VALID(result);
5242 result = Dart_FinalizeLoading(false); 5242 result = Dart_FinalizeLoading(false);
5243 EXPECT_VALID(result); 5243 EXPECT_VALID(result);
5244 5244
5245 // We can invoke both private and non-private local functions. 5245 // We can invoke both private and non-private local functions.
5246 EXPECT_VALID(Dart_Invoke(lib1, NewString("local"), 0, NULL)); 5246 EXPECT_VALID(Dart_Invoke(lib1, NewString("local"), 0, NULL));
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
5896 // Create a test library and Load up a test script in it. 5896 // Create a test library and Load up a test script in it.
5897 Dart_Handle url = NewString(TestCase::url()); 5897 Dart_Handle url = NewString(TestCase::url());
5898 Dart_Handle source = NewString(kScriptChars); 5898 Dart_Handle source = NewString(kScriptChars);
5899 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler); 5899 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler);
5900 EXPECT_VALID(result); 5900 EXPECT_VALID(result);
5901 result = Dart_LoadScript(url, source, 0, 0); 5901 result = Dart_LoadScript(url, source, 0, 0);
5902 EXPECT_VALID(result); 5902 EXPECT_VALID(result);
5903 5903
5904 url = NewString("library1_dart"); 5904 url = NewString("library1_dart");
5905 source = NewString(kLibrary1Chars); 5905 source = NewString(kLibrary1Chars);
5906 result = Dart_LoadLibrary(url, source); 5906 result = Dart_LoadLibrary(url, source, 0, 0);
5907 EXPECT_VALID(result); 5907 EXPECT_VALID(result);
5908 5908
5909 result = Dart_LookupLibrary(url); 5909 result = Dart_LookupLibrary(url);
5910 EXPECT_VALID(result); 5910 EXPECT_VALID(result);
5911 5911
5912 result = Dart_LookupLibrary(Dart_Null()); 5912 result = Dart_LookupLibrary(Dart_Null());
5913 EXPECT(Dart_IsError(result)); 5913 EXPECT(Dart_IsError(result));
5914 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", 5914 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.",
5915 Dart_GetError(result)); 5915 Dart_GetError(result));
5916 5916
(...skipping 13 matching lines...) Expand all
5930 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", 5930 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.",
5931 Dart_GetError(result)); 5931 Dart_GetError(result));
5932 } 5932 }
5933 5933
5934 5934
5935 TEST_CASE(LibraryName) { 5935 TEST_CASE(LibraryName) {
5936 const char* kLibrary1Chars = 5936 const char* kLibrary1Chars =
5937 "library library1_name;"; 5937 "library library1_name;";
5938 Dart_Handle url = NewString("library1_url"); 5938 Dart_Handle url = NewString("library1_url");
5939 Dart_Handle source = NewString(kLibrary1Chars); 5939 Dart_Handle source = NewString(kLibrary1Chars);
5940 Dart_Handle lib = Dart_LoadLibrary(url, source); 5940 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
5941 Dart_Handle error = Dart_NewApiError("incoming error"); 5941 Dart_Handle error = Dart_NewApiError("incoming error");
5942 EXPECT_VALID(lib); 5942 EXPECT_VALID(lib);
5943 5943
5944 Dart_Handle result = Dart_LibraryName(Dart_Null()); 5944 Dart_Handle result = Dart_LibraryName(Dart_Null());
5945 EXPECT(Dart_IsError(result)); 5945 EXPECT(Dart_IsError(result));
5946 EXPECT_STREQ("Dart_LibraryName expects argument 'library' to be non-null.", 5946 EXPECT_STREQ("Dart_LibraryName expects argument 'library' to be non-null.",
5947 Dart_GetError(result)); 5947 Dart_GetError(result));
5948 5948
5949 result = Dart_LibraryName(Dart_True()); 5949 result = Dart_LibraryName(Dart_True());
5950 EXPECT(Dart_IsError(result)); 5950 EXPECT(Dart_IsError(result));
(...skipping 11 matching lines...) Expand all
5962 const char* cstr = NULL; 5962 const char* cstr = NULL;
5963 EXPECT_VALID(Dart_StringToCString(result, &cstr)); 5963 EXPECT_VALID(Dart_StringToCString(result, &cstr));
5964 EXPECT_STREQ("library1_name", cstr); 5964 EXPECT_STREQ("library1_name", cstr);
5965 } 5965 }
5966 5966
5967 TEST_CASE(LibraryId) { 5967 TEST_CASE(LibraryId) {
5968 const char* kLibrary1Chars = 5968 const char* kLibrary1Chars =
5969 "library library1_name;"; 5969 "library library1_name;";
5970 Dart_Handle url = NewString("library1_url"); 5970 Dart_Handle url = NewString("library1_url");
5971 Dart_Handle source = NewString(kLibrary1Chars); 5971 Dart_Handle source = NewString(kLibrary1Chars);
5972 Dart_Handle lib = Dart_LoadLibrary(url, source); 5972 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
5973 Dart_Handle error = Dart_NewApiError("incoming error"); 5973 Dart_Handle error = Dart_NewApiError("incoming error");
5974 EXPECT_VALID(lib); 5974 EXPECT_VALID(lib);
5975 intptr_t libraryId = -1; 5975 intptr_t libraryId = -1;
5976 5976
5977 Dart_Handle result = Dart_LibraryId(Dart_Null(), &libraryId); 5977 Dart_Handle result = Dart_LibraryId(Dart_Null(), &libraryId);
5978 EXPECT(Dart_IsError(result)); 5978 EXPECT(Dart_IsError(result));
5979 EXPECT_STREQ("Dart_LibraryId expects argument 'library' to be non-null.", 5979 EXPECT_STREQ("Dart_LibraryId expects argument 'library' to be non-null.",
5980 Dart_GetError(result)); 5980 Dart_GetError(result));
5981 5981
5982 result = Dart_LibraryId(Dart_True(), &libraryId); 5982 result = Dart_LibraryId(Dart_True(), &libraryId);
(...skipping 16 matching lines...) Expand all
5999 EXPECT_VALID(Dart_StringToCString(result, &cstr)); 5999 EXPECT_VALID(Dart_StringToCString(result, &cstr));
6000 EXPECT_STREQ("library1_name", cstr); 6000 EXPECT_STREQ("library1_name", cstr);
6001 } 6001 }
6002 6002
6003 6003
6004 TEST_CASE(LibraryUrl) { 6004 TEST_CASE(LibraryUrl) {
6005 const char* kLibrary1Chars = 6005 const char* kLibrary1Chars =
6006 "library library1_name;"; 6006 "library library1_name;";
6007 Dart_Handle url = NewString("library1_url"); 6007 Dart_Handle url = NewString("library1_url");
6008 Dart_Handle source = NewString(kLibrary1Chars); 6008 Dart_Handle source = NewString(kLibrary1Chars);
6009 Dart_Handle lib = Dart_LoadLibrary(url, source); 6009 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6010 Dart_Handle error = Dart_NewApiError("incoming error"); 6010 Dart_Handle error = Dart_NewApiError("incoming error");
6011 EXPECT_VALID(lib); 6011 EXPECT_VALID(lib);
6012 6012
6013 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); 6013 Dart_Handle result = Dart_LibraryUrl(Dart_Null());
6014 EXPECT(Dart_IsError(result)); 6014 EXPECT(Dart_IsError(result));
6015 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", 6015 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.",
6016 Dart_GetError(result)); 6016 Dart_GetError(result));
6017 6017
6018 result = Dart_LibraryUrl(Dart_True()); 6018 result = Dart_LibraryUrl(Dart_True());
6019 EXPECT(Dart_IsError(result)); 6019 EXPECT(Dart_IsError(result));
(...skipping 23 matching lines...) Expand all
6043 "abstract class C {}\n" 6043 "abstract class C {}\n"
6044 "class _A {}\n" 6044 "class _A {}\n"
6045 "class _B {}\n" 6045 "class _B {}\n"
6046 "abstract class _C {}\n" 6046 "abstract class _C {}\n"
6047 "\n" 6047 "\n"
6048 "_compare(String a, String b) => a.compareTo(b);\n" 6048 "_compare(String a, String b) => a.compareTo(b);\n"
6049 "sort(list) => list.sort(_compare);\n"; 6049 "sort(list) => list.sort(_compare);\n";
6050 6050
6051 Dart_Handle url = NewString("library_url"); 6051 Dart_Handle url = NewString("library_url");
6052 Dart_Handle source = NewString(kLibraryChars); 6052 Dart_Handle source = NewString(kLibraryChars);
6053 Dart_Handle lib = Dart_LoadLibrary(url, source); 6053 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6054 EXPECT_VALID(lib); 6054 EXPECT_VALID(lib);
6055 Dart_Handle result = Dart_FinalizeLoading(false); 6055 Dart_Handle result = Dart_FinalizeLoading(false);
6056 EXPECT_VALID(result); 6056 EXPECT_VALID(result);
6057 6057
6058 Dart_Handle list = Dart_LibraryGetClassNames(lib); 6058 Dart_Handle list = Dart_LibraryGetClassNames(lib);
6059 EXPECT_VALID(list); 6059 EXPECT_VALID(list);
6060 EXPECT(Dart_IsList(list)); 6060 EXPECT(Dart_IsList(list));
6061 6061
6062 // Sort the list. 6062 // Sort the list.
6063 const int kNumArgs = 1; 6063 const int kNumArgs = 1;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6096 " set _C2(x) { }\n" 6096 " set _C2(x) { }\n"
6097 " var _D2;\n" 6097 " var _D2;\n"
6098 "}\n" 6098 "}\n"
6099 "\n" 6099 "\n"
6100 "_compare(String a, String b) => a.compareTo(b);\n" 6100 "_compare(String a, String b) => a.compareTo(b);\n"
6101 "sort(list) => list.sort(_compare);\n"; 6101 "sort(list) => list.sort(_compare);\n";
6102 6102
6103 // Get the functions from a library. 6103 // Get the functions from a library.
6104 Dart_Handle url = NewString("library_url"); 6104 Dart_Handle url = NewString("library_url");
6105 Dart_Handle source = NewString(kLibraryChars); 6105 Dart_Handle source = NewString(kLibraryChars);
6106 Dart_Handle lib = Dart_LoadLibrary(url, source); 6106 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6107 EXPECT_VALID(lib); 6107 EXPECT_VALID(lib);
6108 Dart_Handle result = Dart_FinalizeLoading(false); 6108 Dart_Handle result = Dart_FinalizeLoading(false);
6109 EXPECT_VALID(result); 6109 EXPECT_VALID(result);
6110 6110
6111 Dart_Handle list = Dart_GetFunctionNames(lib); 6111 Dart_Handle list = Dart_GetFunctionNames(lib);
6112 EXPECT_VALID(list); 6112 EXPECT_VALID(list);
6113 EXPECT(Dart_IsList(list)); 6113 EXPECT(Dart_IsList(list));
6114 6114
6115 // Sort the list. 6115 // Sort the list.
6116 const int kNumArgs = 1; 6116 const int kNumArgs = 1;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6148 TEST_CASE(LibraryImportLibrary) { 6148 TEST_CASE(LibraryImportLibrary) {
6149 const char* kLibrary1Chars = 6149 const char* kLibrary1Chars =
6150 "library library1_name;"; 6150 "library library1_name;";
6151 const char* kLibrary2Chars = 6151 const char* kLibrary2Chars =
6152 "library library2_name;"; 6152 "library library2_name;";
6153 Dart_Handle error = Dart_NewApiError("incoming error"); 6153 Dart_Handle error = Dart_NewApiError("incoming error");
6154 Dart_Handle result; 6154 Dart_Handle result;
6155 6155
6156 Dart_Handle url = NewString("library1_url"); 6156 Dart_Handle url = NewString("library1_url");
6157 Dart_Handle source = NewString(kLibrary1Chars); 6157 Dart_Handle source = NewString(kLibrary1Chars);
6158 Dart_Handle lib1 = Dart_LoadLibrary(url, source); 6158 Dart_Handle lib1 = Dart_LoadLibrary(url, source, 0, 0);
6159 EXPECT_VALID(lib1); 6159 EXPECT_VALID(lib1);
6160 6160
6161 url = NewString("library2_url"); 6161 url = NewString("library2_url");
6162 source = NewString(kLibrary2Chars); 6162 source = NewString(kLibrary2Chars);
6163 Dart_Handle lib2 = Dart_LoadLibrary(url, source); 6163 Dart_Handle lib2 = Dart_LoadLibrary(url, source, 0, 0);
6164 EXPECT_VALID(lib2); 6164 EXPECT_VALID(lib2);
6165 6165
6166 result = Dart_LibraryImportLibrary(Dart_Null(), lib2, Dart_Null()); 6166 result = Dart_LibraryImportLibrary(Dart_Null(), lib2, Dart_Null());
6167 EXPECT(Dart_IsError(result)); 6167 EXPECT(Dart_IsError(result));
6168 EXPECT_STREQ( 6168 EXPECT_STREQ(
6169 "Dart_LibraryImportLibrary expects argument 'library' to be non-null.", 6169 "Dart_LibraryImportLibrary expects argument 'library' to be non-null.",
6170 Dart_GetError(result)); 6170 Dart_GetError(result));
6171 6171
6172 result = Dart_LibraryImportLibrary(Dart_True(), lib2, Dart_Null()); 6172 result = Dart_LibraryImportLibrary(Dart_True(), lib2, Dart_Null());
6173 EXPECT(Dart_IsError(result)); 6173 EXPECT(Dart_IsError(result));
(...skipping 25 matching lines...) Expand all
6199 EXPECT_VALID(result); 6199 EXPECT_VALID(result);
6200 } 6200 }
6201 6201
6202 6202
6203 TEST_CASE(ImportLibraryWithPrefix) { 6203 TEST_CASE(ImportLibraryWithPrefix) {
6204 const char* kLibrary1Chars = 6204 const char* kLibrary1Chars =
6205 "library library1_name;" 6205 "library library1_name;"
6206 "int bar() => 42;"; 6206 "int bar() => 42;";
6207 Dart_Handle url1 = NewString("library1_url"); 6207 Dart_Handle url1 = NewString("library1_url");
6208 Dart_Handle source1 = NewString(kLibrary1Chars); 6208 Dart_Handle source1 = NewString(kLibrary1Chars);
6209 Dart_Handle lib1 = Dart_LoadLibrary(url1, source1); 6209 Dart_Handle lib1 = Dart_LoadLibrary(url1, source1, 0, 0);
6210 EXPECT_VALID(lib1); 6210 EXPECT_VALID(lib1);
6211 EXPECT(Dart_IsLibrary(lib1)); 6211 EXPECT(Dart_IsLibrary(lib1));
6212 6212
6213 const char* kLibrary2Chars = 6213 const char* kLibrary2Chars =
6214 "library library2_name;" 6214 "library library2_name;"
6215 "int foobar() => foo.bar();"; 6215 "int foobar() => foo.bar();";
6216 Dart_Handle url2 = NewString("library2_url"); 6216 Dart_Handle url2 = NewString("library2_url");
6217 Dart_Handle source2 = NewString(kLibrary2Chars); 6217 Dart_Handle source2 = NewString(kLibrary2Chars);
6218 Dart_Handle lib2 = Dart_LoadLibrary(url2, source2); 6218 Dart_Handle lib2 = Dart_LoadLibrary(url2, source2, 0, 0);
6219 EXPECT_VALID(lib2); 6219 EXPECT_VALID(lib2);
6220 EXPECT(Dart_IsLibrary(lib2)); 6220 EXPECT(Dart_IsLibrary(lib2));
6221 6221
6222 Dart_Handle prefix = NewString("foo"); 6222 Dart_Handle prefix = NewString("foo");
6223 Dart_Handle result = Dart_LibraryImportLibrary(lib2, lib1, prefix); 6223 Dart_Handle result = Dart_LibraryImportLibrary(lib2, lib1, prefix);
6224 EXPECT_VALID(result); 6224 EXPECT_VALID(result);
6225 result = Dart_FinalizeLoading(false); 6225 result = Dart_FinalizeLoading(false);
6226 EXPECT_VALID(result); 6226 EXPECT_VALID(result);
6227 6227
6228 // Lib1 is imported under a library prefix and therefore 'foo' should 6228 // Lib1 is imported under a library prefix and therefore 'foo' should
(...skipping 16 matching lines...) Expand all
6245 6245
6246 TEST_CASE(LoadLibrary) { 6246 TEST_CASE(LoadLibrary) {
6247 const char* kLibrary1Chars = 6247 const char* kLibrary1Chars =
6248 "library library1_name;"; 6248 "library library1_name;";
6249 Dart_Handle error = Dart_NewApiError("incoming error"); 6249 Dart_Handle error = Dart_NewApiError("incoming error");
6250 Dart_Handle result; 6250 Dart_Handle result;
6251 6251
6252 Dart_Handle url = NewString("library1_url"); 6252 Dart_Handle url = NewString("library1_url");
6253 Dart_Handle source = NewString(kLibrary1Chars); 6253 Dart_Handle source = NewString(kLibrary1Chars);
6254 6254
6255 result = Dart_LoadLibrary(Dart_Null(), source); 6255 result = Dart_LoadLibrary(Dart_Null(), source, 0, 0);
6256 EXPECT(Dart_IsError(result)); 6256 EXPECT(Dart_IsError(result));
6257 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.", 6257 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.",
6258 Dart_GetError(result)); 6258 Dart_GetError(result));
6259 6259
6260 result = Dart_LoadLibrary(Dart_True(), source); 6260 result = Dart_LoadLibrary(Dart_True(), source, 0, 0);
6261 EXPECT(Dart_IsError(result)); 6261 EXPECT(Dart_IsError(result));
6262 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.", 6262 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.",
6263 Dart_GetError(result)); 6263 Dart_GetError(result));
6264 6264
6265 result = Dart_LoadLibrary(error, source); 6265 result = Dart_LoadLibrary(error, source, 0, 0);
6266 EXPECT(Dart_IsError(result)); 6266 EXPECT(Dart_IsError(result));
6267 EXPECT_STREQ("incoming error", Dart_GetError(result)); 6267 EXPECT_STREQ("incoming error", Dart_GetError(result));
6268 6268
6269 result = Dart_LoadLibrary(url, Dart_Null()); 6269 result = Dart_LoadLibrary(url, Dart_Null(), 0, 0);
6270 EXPECT(Dart_IsError(result)); 6270 EXPECT(Dart_IsError(result));
6271 EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.", 6271 EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.",
6272 Dart_GetError(result)); 6272 Dart_GetError(result));
6273 6273
6274 result = Dart_LoadLibrary(url, Dart_True()); 6274 result = Dart_LoadLibrary(url, Dart_True(), 0, 0);
6275 EXPECT(Dart_IsError(result)); 6275 EXPECT(Dart_IsError(result));
6276 EXPECT_STREQ( 6276 EXPECT_STREQ(
6277 "Dart_LoadLibrary expects argument 'source' to be of type String.", 6277 "Dart_LoadLibrary expects argument 'source' to be of type String.",
6278 Dart_GetError(result)); 6278 Dart_GetError(result));
6279 6279
6280 result = Dart_LoadLibrary(url, error); 6280 result = Dart_LoadLibrary(url, error, 0, 0);
6281 EXPECT(Dart_IsError(result)); 6281 EXPECT(Dart_IsError(result));
6282 EXPECT_STREQ("incoming error", Dart_GetError(result)); 6282 EXPECT_STREQ("incoming error", Dart_GetError(result));
6283 6283
6284 // Success. 6284 // Success.
6285 result = Dart_LoadLibrary(url, source); 6285 result = Dart_LoadLibrary(url, source, 0, 0);
6286 EXPECT_VALID(result); 6286 EXPECT_VALID(result);
6287 EXPECT(Dart_IsLibrary(result)); 6287 EXPECT(Dart_IsLibrary(result));
6288 6288
6289 // Duplicate library load fails. 6289 // Duplicate library load fails.
6290 result = Dart_LoadLibrary(url, source); 6290 result = Dart_LoadLibrary(url, source, 0, 0);
6291 EXPECT(Dart_IsError(result)); 6291 EXPECT(Dart_IsError(result));
6292 EXPECT_STREQ( 6292 EXPECT_STREQ(
6293 "Dart_LoadLibrary: library 'library1_url' has already been loaded.", 6293 "Dart_LoadLibrary: library 'library1_url' has already been loaded.",
6294 Dart_GetError(result)); 6294 Dart_GetError(result));
6295 } 6295 }
6296 6296
6297 6297
6298 TEST_CASE(LoadLibrary_CompileError) { 6298 TEST_CASE(LoadLibrary_CompileError) {
6299 const char* kLibrary1Chars = 6299 const char* kLibrary1Chars =
6300 "library library1_name;" 6300 "library library1_name;"
6301 ")"; 6301 ")";
6302 Dart_Handle url = NewString("library1_url"); 6302 Dart_Handle url = NewString("library1_url");
6303 Dart_Handle source = NewString(kLibrary1Chars); 6303 Dart_Handle source = NewString(kLibrary1Chars);
6304 Dart_Handle result = Dart_LoadLibrary(url, source); 6304 Dart_Handle result = Dart_LoadLibrary(url, source, 0, 0);
6305 EXPECT(Dart_IsError(result)); 6305 EXPECT(Dart_IsError(result));
6306 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); 6306 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
6307 } 6307 }
6308 6308
6309 6309
6310 TEST_CASE(LoadSource) { 6310 TEST_CASE(LoadSource) {
6311 const char* kLibrary1Chars = 6311 const char* kLibrary1Chars =
6312 "library library1_name;"; 6312 "library library1_name;";
6313 const char* kSourceChars = 6313 const char* kSourceChars =
6314 "part of library1_name;\n// Something innocuous"; 6314 "part of library1_name;\n// Something innocuous";
6315 const char* kBadSourceChars = 6315 const char* kBadSourceChars =
6316 ")"; 6316 ")";
6317 Dart_Handle error = Dart_NewApiError("incoming error"); 6317 Dart_Handle error = Dart_NewApiError("incoming error");
6318 Dart_Handle result; 6318 Dart_Handle result;
6319 6319
6320 // Load up a library. 6320 // Load up a library.
6321 Dart_Handle url = NewString("library1_url"); 6321 Dart_Handle url = NewString("library1_url");
6322 Dart_Handle source = NewString(kLibrary1Chars); 6322 Dart_Handle source = NewString(kLibrary1Chars);
6323 Dart_Handle lib = Dart_LoadLibrary(url, source); 6323 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6324 EXPECT_VALID(lib); 6324 EXPECT_VALID(lib);
6325 EXPECT(Dart_IsLibrary(lib)); 6325 EXPECT(Dart_IsLibrary(lib));
6326 6326
6327 url = NewString("source_url"); 6327 url = NewString("source_url");
6328 source = NewString(kSourceChars); 6328 source = NewString(kSourceChars);
6329 6329
6330 result = Dart_LoadSource(Dart_Null(), url, source); 6330 result = Dart_LoadSource(Dart_Null(), url, source, 0, 0);
6331 EXPECT(Dart_IsError(result)); 6331 EXPECT(Dart_IsError(result));
6332 EXPECT_STREQ("Dart_LoadSource expects argument 'library' to be non-null.", 6332 EXPECT_STREQ("Dart_LoadSource expects argument 'library' to be non-null.",
6333 Dart_GetError(result)); 6333 Dart_GetError(result));
6334 6334
6335 result = Dart_LoadSource(Dart_True(), url, source); 6335 result = Dart_LoadSource(Dart_True(), url, source, 0, 0);
6336 EXPECT(Dart_IsError(result)); 6336 EXPECT(Dart_IsError(result));
6337 EXPECT_STREQ( 6337 EXPECT_STREQ(
6338 "Dart_LoadSource expects argument 'library' to be of type Library.", 6338 "Dart_LoadSource expects argument 'library' to be of type Library.",
6339 Dart_GetError(result)); 6339 Dart_GetError(result));
6340 6340
6341 result = Dart_LoadSource(error, url, source); 6341 result = Dart_LoadSource(error, url, source, 0, 0);
6342 EXPECT(Dart_IsError(result)); 6342 EXPECT(Dart_IsError(result));
6343 EXPECT_STREQ("incoming error", Dart_GetError(result)); 6343 EXPECT_STREQ("incoming error", Dart_GetError(result));
6344 6344
6345 result = Dart_LoadSource(lib, Dart_Null(), source); 6345 result = Dart_LoadSource(lib, Dart_Null(), source, 0, 0);
6346 EXPECT(Dart_IsError(result)); 6346 EXPECT(Dart_IsError(result));
6347 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be non-null.", 6347 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be non-null.",
6348 Dart_GetError(result)); 6348 Dart_GetError(result));
6349 6349
6350 result = Dart_LoadSource(lib, Dart_True(), source); 6350 result = Dart_LoadSource(lib, Dart_True(), source, 0, 0);
6351 EXPECT(Dart_IsError(result)); 6351 EXPECT(Dart_IsError(result));
6352 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be of type String.", 6352 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be of type String.",
6353 Dart_GetError(result)); 6353 Dart_GetError(result));
6354 6354
6355 result = Dart_LoadSource(lib, error, source); 6355 result = Dart_LoadSource(lib, error, source, 0, 0);
6356 EXPECT(Dart_IsError(result)); 6356 EXPECT(Dart_IsError(result));
6357 EXPECT_STREQ("incoming error", Dart_GetError(result)); 6357 EXPECT_STREQ("incoming error", Dart_GetError(result));
6358 6358
6359 result = Dart_LoadSource(lib, url, Dart_Null()); 6359 result = Dart_LoadSource(lib, url, Dart_Null(), 0, 0);
6360 EXPECT(Dart_IsError(result)); 6360 EXPECT(Dart_IsError(result));
6361 EXPECT_STREQ("Dart_LoadSource expects argument 'source' to be non-null.", 6361 EXPECT_STREQ("Dart_LoadSource expects argument 'source' to be non-null.",
6362 Dart_GetError(result)); 6362 Dart_GetError(result));
6363 6363
6364 result = Dart_LoadSource(lib, url, Dart_True()); 6364 result = Dart_LoadSource(lib, url, Dart_True(), 0, 0);
6365 EXPECT(Dart_IsError(result)); 6365 EXPECT(Dart_IsError(result));
6366 EXPECT_STREQ( 6366 EXPECT_STREQ(
6367 "Dart_LoadSource expects argument 'source' to be of type String.", 6367 "Dart_LoadSource expects argument 'source' to be of type String.",
6368 Dart_GetError(result)); 6368 Dart_GetError(result));
6369 6369
6370 result = Dart_LoadSource(lib, error, source); 6370 result = Dart_LoadSource(lib, error, source, 0, 0);
6371 EXPECT(Dart_IsError(result)); 6371 EXPECT(Dart_IsError(result));
6372 EXPECT_STREQ("incoming error", Dart_GetError(result)); 6372 EXPECT_STREQ("incoming error", Dart_GetError(result));
6373 6373
6374 // Success. 6374 // Success.
6375 result = Dart_LoadSource(lib, url, source); 6375 result = Dart_LoadSource(lib, url, source, 0, 0);
6376 EXPECT_VALID(result); 6376 EXPECT_VALID(result);
6377 EXPECT(Dart_IsLibrary(result)); 6377 EXPECT(Dart_IsLibrary(result));
6378 EXPECT(Dart_IdentityEquals(lib, result)); 6378 EXPECT(Dart_IdentityEquals(lib, result));
6379 6379
6380 // Duplicate calls are okay. 6380 // Duplicate calls are okay.
6381 result = Dart_LoadSource(lib, url, source); 6381 result = Dart_LoadSource(lib, url, source, 0, 0);
6382 EXPECT_VALID(result); 6382 EXPECT_VALID(result);
6383 EXPECT(Dart_IsLibrary(result)); 6383 EXPECT(Dart_IsLibrary(result));
6384 EXPECT(Dart_IdentityEquals(lib, result)); 6384 EXPECT(Dart_IdentityEquals(lib, result));
6385 6385
6386 // Language errors are detected. 6386 // Language errors are detected.
6387 source = NewString(kBadSourceChars); 6387 source = NewString(kBadSourceChars);
6388 result = Dart_LoadSource(lib, url, source); 6388 result = Dart_LoadSource(lib, url, source, 0, 0);
6389 EXPECT(Dart_IsError(result)); 6389 EXPECT(Dart_IsError(result));
6390 } 6390 }
6391 6391
6392 6392
6393 TEST_CASE(LoadSource_LateLoad) { 6393 TEST_CASE(LoadSource_LateLoad) {
6394 const char* kLibrary1Chars = 6394 const char* kLibrary1Chars =
6395 "library library1_name;\n" 6395 "library library1_name;\n"
6396 "class OldClass {\n" 6396 "class OldClass {\n"
6397 " foo() => 'foo';\n" 6397 " foo() => 'foo';\n"
6398 "}\n"; 6398 "}\n";
6399 const char* kSourceChars = 6399 const char* kSourceChars =
6400 "part of library1_name;\n" 6400 "part of library1_name;\n"
6401 "class NewClass extends OldClass{\n" 6401 "class NewClass extends OldClass{\n"
6402 " bar() => 'bar';\n" 6402 " bar() => 'bar';\n"
6403 "}\n"; 6403 "}\n";
6404 Dart_Handle url = NewString("library1_url"); 6404 Dart_Handle url = NewString("library1_url");
6405 Dart_Handle source = NewString(kLibrary1Chars); 6405 Dart_Handle source = NewString(kLibrary1Chars);
6406 Dart_Handle lib = Dart_LoadLibrary(url, source); 6406 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6407 EXPECT_VALID(lib); 6407 EXPECT_VALID(lib);
6408 EXPECT(Dart_IsLibrary(lib)); 6408 EXPECT(Dart_IsLibrary(lib));
6409 Dart_Handle result = Dart_FinalizeLoading(false); 6409 Dart_Handle result = Dart_FinalizeLoading(false);
6410 EXPECT_VALID(result); 6410 EXPECT_VALID(result);
6411 6411
6412 // Call a dynamic function on OldClass. 6412 // Call a dynamic function on OldClass.
6413 Dart_Handle type = Dart_GetType(lib, NewString("OldClass"), 0, NULL); 6413 Dart_Handle type = Dart_GetType(lib, NewString("OldClass"), 0, NULL);
6414 EXPECT_VALID(type); 6414 EXPECT_VALID(type);
6415 Dart_Handle recv = Dart_New(type, Dart_Null(), 0, NULL); 6415 Dart_Handle recv = Dart_New(type, Dart_Null(), 0, NULL);
6416 result = Dart_Invoke(recv, NewString("foo"), 0, NULL); 6416 result = Dart_Invoke(recv, NewString("foo"), 0, NULL);
6417 EXPECT_VALID(result); 6417 EXPECT_VALID(result);
6418 EXPECT(Dart_IsString(result)); 6418 EXPECT(Dart_IsString(result));
6419 const char* result_cstr = ""; 6419 const char* result_cstr = "";
6420 EXPECT_VALID(Dart_StringToCString(result, &result_cstr)); 6420 EXPECT_VALID(Dart_StringToCString(result, &result_cstr));
6421 EXPECT_STREQ("foo", result_cstr); 6421 EXPECT_STREQ("foo", result_cstr);
6422 6422
6423 // Load a source file late. 6423 // Load a source file late.
6424 url = NewString("source_url"); 6424 url = NewString("source_url");
6425 source = NewString(kSourceChars); 6425 source = NewString(kSourceChars);
6426 EXPECT_VALID(Dart_LoadSource(lib, url, source)); 6426 EXPECT_VALID(Dart_LoadSource(lib, url, source, 0, 0));
6427 result = Dart_FinalizeLoading(false); 6427 result = Dart_FinalizeLoading(false);
6428 EXPECT_VALID(result); 6428 EXPECT_VALID(result);
6429 6429
6430 // Call a dynamic function on NewClass in the updated library. 6430 // Call a dynamic function on NewClass in the updated library.
6431 type = Dart_GetType(lib, NewString("NewClass"), 0, NULL); 6431 type = Dart_GetType(lib, NewString("NewClass"), 0, NULL);
6432 EXPECT_VALID(type); 6432 EXPECT_VALID(type);
6433 recv = Dart_New(type, Dart_Null(), 0, NULL); 6433 recv = Dart_New(type, Dart_Null(), 0, NULL);
6434 result = Dart_Invoke(recv, NewString("bar"), 0, NULL); 6434 result = Dart_Invoke(recv, NewString("bar"), 0, NULL);
6435 EXPECT_VALID(result); 6435 EXPECT_VALID(result);
6436 EXPECT(Dart_IsString(result)); 6436 EXPECT(Dart_IsString(result));
6437 result_cstr = ""; 6437 result_cstr = "";
6438 EXPECT_VALID(Dart_StringToCString(result, &result_cstr)); 6438 EXPECT_VALID(Dart_StringToCString(result, &result_cstr));
6439 EXPECT_STREQ("bar", result_cstr); 6439 EXPECT_STREQ("bar", result_cstr);
6440 } 6440 }
6441 6441
6442 6442
6443 TEST_CASE(LoadPatch) { 6443 TEST_CASE(LoadPatch) {
6444 const char* kLibrary1Chars = 6444 const char* kLibrary1Chars =
6445 "library library1_name;"; 6445 "library library1_name;";
6446 const char* kSourceChars = 6446 const char* kSourceChars =
6447 "part of library1_name;\n" 6447 "part of library1_name;\n"
6448 "external int foo();"; 6448 "external int foo();";
6449 const char* kPatchChars = 6449 const char* kPatchChars =
6450 "patch int foo() => 42;"; 6450 "patch int foo() => 42;";
6451 6451
6452 // Load up a library. 6452 // Load up a library.
6453 Dart_Handle url = NewString("library1_url"); 6453 Dart_Handle url = NewString("library1_url");
6454 Dart_Handle source = NewString(kLibrary1Chars); 6454 Dart_Handle source = NewString(kLibrary1Chars);
6455 Dart_Handle lib = Dart_LoadLibrary(url, source); 6455 Dart_Handle lib = Dart_LoadLibrary(url, source, 0, 0);
6456 EXPECT_VALID(lib); 6456 EXPECT_VALID(lib);
6457 EXPECT(Dart_IsLibrary(lib)); 6457 EXPECT(Dart_IsLibrary(lib));
6458 6458
6459 url = NewString("source_url"); 6459 url = NewString("source_url");
6460 source = NewString(kSourceChars); 6460 source = NewString(kSourceChars);
6461 6461
6462 Dart_Handle result = Dart_LoadSource(lib, url, source); 6462 Dart_Handle result = Dart_LoadSource(lib, url, source, 0, 0);
6463 EXPECT_VALID(result); 6463 EXPECT_VALID(result);
6464 6464
6465 url = NewString("patch_url"); 6465 url = NewString("patch_url");
6466 source = NewString(kPatchChars); 6466 source = NewString(kPatchChars);
6467 6467
6468 result = Dart_LibraryLoadPatch(lib, url, source); 6468 result = Dart_LibraryLoadPatch(lib, url, source);
6469 EXPECT_VALID(result); 6469 EXPECT_VALID(result);
6470 result = Dart_FinalizeLoading(false); 6470 result = Dart_FinalizeLoading(false);
6471 EXPECT_VALID(result); 6471 EXPECT_VALID(result);
6472 6472
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
6577 ; // NOLINT 6577 ; // NOLINT
6578 6578
6579 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 6579 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
6580 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 6580 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
6581 6581
6582 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler); 6582 Dart_Handle result = Dart_SetLibraryTagHandler(library_handler);
6583 EXPECT_VALID(result); 6583 EXPECT_VALID(result);
6584 6584
6585 Dart_Handle url = NewString("theLibrary"); 6585 Dart_Handle url = NewString("theLibrary");
6586 Dart_Handle source = NewString(kLibraryChars); 6586 Dart_Handle source = NewString(kLibraryChars);
6587 result = Dart_LoadLibrary(url, source); 6587 result = Dart_LoadLibrary(url, source, 0, 0);
6588 EXPECT_VALID(result); 6588 EXPECT_VALID(result);
6589 6589
6590 const char* patchNames[] = { "main library patch", 6590 const char* patchNames[] = { "main library patch",
6591 "patch class only", 6591 "patch class only",
6592 "patch no class" }; 6592 "patch no class" };
6593 const char* patches[] = { kPatchChars, 6593 const char* patches[] = { kPatchChars,
6594 kPatchClassOnlyChars, 6594 kPatchClassOnlyChars,
6595 kPatchNoClassChars }; 6595 kPatchNoClassChars };
6596 const String& lib_url = String::Handle(String::New("theLibrary")); 6596 const String& lib_url = String::Handle(String::New("theLibrary"));
6597 6597
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
6801 Dart_Handle result; 6801 Dart_Handle result;
6802 // Create a test library and Load up a test script in it. 6802 // Create a test library and Load up a test script in it.
6803 Dart_Handle url = NewString(TestCase::url()); 6803 Dart_Handle url = NewString(TestCase::url());
6804 Dart_Handle source = NewString(kScriptChars); 6804 Dart_Handle source = NewString(kScriptChars);
6805 result = Dart_SetLibraryTagHandler(library_handler); 6805 result = Dart_SetLibraryTagHandler(library_handler);
6806 EXPECT_VALID(result); 6806 EXPECT_VALID(result);
6807 result = Dart_LoadScript(url, source, 0, 0); 6807 result = Dart_LoadScript(url, source, 0, 0);
6808 6808
6809 url = NewString("library1_dart"); 6809 url = NewString("library1_dart");
6810 source = NewString(kLibrary1Chars); 6810 source = NewString(kLibrary1Chars);
6811 Dart_LoadLibrary(url, source); 6811 Dart_LoadLibrary(url, source, 0, 0);
6812 6812
6813 url = NewString("library2_dart"); 6813 url = NewString("library2_dart");
6814 source = NewString(kLibrary2Chars); 6814 source = NewString(kLibrary2Chars);
6815 Dart_LoadLibrary(url, source); 6815 Dart_LoadLibrary(url, source, 0, 0);
6816 6816
6817 Dart_FinalizeLoading(false); 6817 Dart_FinalizeLoading(false);
6818 6818
6819 result = Dart_Invoke(result, NewString("main"), 0, NULL); 6819 result = Dart_Invoke(result, NewString("main"), 0, NULL);
6820 EXPECT_VALID(result); 6820 EXPECT_VALID(result);
6821 } 6821 }
6822 6822
6823 6823
6824 // Test that if the same name is imported from two libraries, it is 6824 // Test that if the same name is imported from two libraries, it is
6825 // an error if that name is referenced. 6825 // an error if that name is referenced.
(...skipping 14 matching lines...) Expand all
6840 // Create a test library and Load up a test script in it. 6840 // Create a test library and Load up a test script in it.
6841 Dart_Handle url = NewString(TestCase::url()); 6841 Dart_Handle url = NewString(TestCase::url());
6842 Dart_Handle source = NewString(kScriptChars); 6842 Dart_Handle source = NewString(kScriptChars);
6843 result = Dart_SetLibraryTagHandler(library_handler); 6843 result = Dart_SetLibraryTagHandler(library_handler);
6844 EXPECT_VALID(result); 6844 EXPECT_VALID(result);
6845 result = Dart_LoadScript(url, source, 0, 0); 6845 result = Dart_LoadScript(url, source, 0, 0);
6846 EXPECT_VALID(result); 6846 EXPECT_VALID(result);
6847 6847
6848 url = NewString("library2_dart"); 6848 url = NewString("library2_dart");
6849 source = NewString(kLibrary2Chars); 6849 source = NewString(kLibrary2Chars);
6850 Dart_LoadLibrary(url, source); 6850 Dart_LoadLibrary(url, source, 0, 0);
6851 6851
6852 url = NewString("library1_dart"); 6852 url = NewString("library1_dart");
6853 source = NewString(kLibrary1Chars); 6853 source = NewString(kLibrary1Chars);
6854 Dart_LoadLibrary(url, source); 6854 Dart_LoadLibrary(url, source, 0, 0);
6855 result = Dart_FinalizeLoading(false); 6855 result = Dart_FinalizeLoading(false);
6856 EXPECT_VALID(result); 6856 EXPECT_VALID(result);
6857 6857
6858 result = Dart_Invoke(result, NewString("main"), 0, NULL); 6858 result = Dart_Invoke(result, NewString("main"), 0, NULL);
6859 EXPECT(Dart_IsError(result)); 6859 EXPECT(Dart_IsError(result));
6860 EXPECT_SUBSTRING("NoSuchMethodError", Dart_GetError(result)); 6860 EXPECT_SUBSTRING("NoSuchMethodError", Dart_GetError(result));
6861 } 6861 }
6862 6862
6863 6863
6864 // Test that if the same name is imported from two libraries, it is 6864 // Test that if the same name is imported from two libraries, it is
(...skipping 14 matching lines...) Expand all
6879 // Create a test library and Load up a test script in it. 6879 // Create a test library and Load up a test script in it.
6880 Dart_Handle url = NewString(TestCase::url()); 6880 Dart_Handle url = NewString(TestCase::url());
6881 Dart_Handle source = NewString(kScriptChars); 6881 Dart_Handle source = NewString(kScriptChars);
6882 result = Dart_SetLibraryTagHandler(library_handler); 6882 result = Dart_SetLibraryTagHandler(library_handler);
6883 EXPECT_VALID(result); 6883 EXPECT_VALID(result);
6884 result = Dart_LoadScript(url, source, 0, 0); 6884 result = Dart_LoadScript(url, source, 0, 0);
6885 EXPECT_VALID(result); 6885 EXPECT_VALID(result);
6886 6886
6887 url = NewString("library2_dart"); 6887 url = NewString("library2_dart");
6888 source = NewString(kLibrary2Chars); 6888 source = NewString(kLibrary2Chars);
6889 Dart_LoadLibrary(url, source); 6889 Dart_LoadLibrary(url, source, 0, 0);
6890 6890
6891 url = NewString("library1_dart"); 6891 url = NewString("library1_dart");
6892 source = NewString(kLibrary1Chars); 6892 source = NewString(kLibrary1Chars);
6893 Dart_LoadLibrary(url, source); 6893 Dart_LoadLibrary(url, source, 0, 0);
6894 Dart_FinalizeLoading(false); 6894 Dart_FinalizeLoading(false);
6895 6895
6896 result = Dart_Invoke(result, NewString("main"), 0, NULL); 6896 result = Dart_Invoke(result, NewString("main"), 0, NULL);
6897 EXPECT_VALID(result); 6897 EXPECT_VALID(result);
6898 } 6898 }
6899 6899
6900 6900
6901 TEST_CASE(ImportLibrary5) { 6901 TEST_CASE(ImportLibrary5) {
6902 const char* kScriptChars = 6902 const char* kScriptChars =
6903 "import 'lib.dart';\n" 6903 "import 'lib.dart';\n"
(...skipping 10 matching lines...) Expand all
6914 6914
6915 // Create a test library and Load up a test script in it. 6915 // Create a test library and Load up a test script in it.
6916 Dart_Handle url = NewString(TestCase::url()); 6916 Dart_Handle url = NewString(TestCase::url());
6917 Dart_Handle source = NewString(kScriptChars); 6917 Dart_Handle source = NewString(kScriptChars);
6918 result = Dart_SetLibraryTagHandler(library_handler); 6918 result = Dart_SetLibraryTagHandler(library_handler);
6919 EXPECT_VALID(result); 6919 EXPECT_VALID(result);
6920 result = Dart_LoadScript(url, source, 0, 0); 6920 result = Dart_LoadScript(url, source, 0, 0);
6921 6921
6922 url = NewString("lib.dart"); 6922 url = NewString("lib.dart");
6923 source = NewString(kLibraryChars); 6923 source = NewString(kLibraryChars);
6924 Dart_LoadLibrary(url, source); 6924 Dart_LoadLibrary(url, source, 0, 0);
6925 Dart_FinalizeLoading(false); 6925 Dart_FinalizeLoading(false);
6926 6926
6927 result = Dart_Invoke(result, NewString("main"), 0, NULL); 6927 result = Dart_Invoke(result, NewString("main"), 0, NULL);
6928 EXPECT_VALID(result); 6928 EXPECT_VALID(result);
6929 } 6929 }
6930 6930
6931 6931
6932 void NewNativePort_send123(Dart_Port dest_port_id, 6932 void NewNativePort_send123(Dart_Port dest_port_id,
6933 Dart_CObject *message) { 6933 Dart_CObject *message) {
6934 // Gets a send port message. 6934 // Gets a send port message.
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
8393 Dart_Handle result; 8393 Dart_Handle result;
8394 // Create a test library and Load up a test script in it. 8394 // Create a test library and Load up a test script in it.
8395 Dart_Handle lib1 = TestCase::LoadTestScript(kLoadFirst, NULL); 8395 Dart_Handle lib1 = TestCase::LoadTestScript(kLoadFirst, NULL);
8396 Dart_Handle dart_args[1]; 8396 Dart_Handle dart_args[1];
8397 dart_args[0] = Dart_NewInteger(0); 8397 dart_args[0] = Dart_NewInteger(0);
8398 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args); 8398 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args);
8399 EXPECT_VALID(result); 8399 EXPECT_VALID(result);
8400 8400
8401 Dart_Handle source = NewString(kLoadSecond); 8401 Dart_Handle source = NewString(kLoadSecond);
8402 Dart_Handle url = NewString(TestCase::url()); 8402 Dart_Handle url = NewString(TestCase::url());
8403 Dart_LoadSource(TestCase::lib(), url, source); 8403 Dart_LoadSource(TestCase::lib(), url, source, 0, 0);
8404 result = Dart_FinalizeLoading(false); 8404 result = Dart_FinalizeLoading(false);
8405 EXPECT_VALID(result); 8405 EXPECT_VALID(result);
8406 8406
8407 dart_args[0] = Dart_NewInteger(1); 8407 dart_args[0] = Dart_NewInteger(1);
8408 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args); 8408 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args);
8409 EXPECT_VALID(result); 8409 EXPECT_VALID(result);
8410 } 8410 }
8411 8411
8412 8412
8413 // Test external strings and optimized code. 8413 // Test external strings and optimized code.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
8606 NewString("main"), 8606 NewString("main"),
8607 1, 8607 1,
8608 dart_args); 8608 dart_args);
8609 int64_t value = 0; 8609 int64_t value = 0;
8610 result = Dart_IntegerToInt64(result, &value); 8610 result = Dart_IntegerToInt64(result, &value);
8611 EXPECT_VALID(result); 8611 EXPECT_VALID(result);
8612 EXPECT_EQ(6, value); 8612 EXPECT_EQ(6, value);
8613 } 8613 }
8614 8614
8615 } // namespace dart 8615 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698