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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 10332257: Revert my last change. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 7756)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -2315,7 +2315,8 @@
// Load imported lib.
Dart_Handle url = Dart_NewString("library_url");
Dart_Handle source = Dart_NewString(kImportedScriptChars);
- Dart_Handle imported_lib = Dart_LoadLibrary(url, source);
+ Dart_Handle import_map = Dart_NewList(0);
+ Dart_Handle imported_lib = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(imported_lib);
Dart_Handle result = Dart_LibraryImportLibrary(lib, imported_lib);
EXPECT_VALID(result);
@@ -3277,13 +3278,14 @@
// Load lib1
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
- Dart_Handle lib1 = Dart_LoadLibrary(url, source);
+ Dart_Handle import_map = Dart_NewList(0);
+ Dart_Handle lib1 = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(lib1);
// Load lib2
url = Dart_NewString("library2_url");
source = Dart_NewString(kLibrary2Chars);
- Dart_Handle lib2 = Dart_LoadLibrary(url, source);
+ Dart_Handle lib2 = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(lib2);
// Import lib2 from lib1
@@ -3559,7 +3561,8 @@
static Dart_Handle library_handler(Dart_LibraryTag tag,
Dart_Handle library,
- Dart_Handle url) {
+ Dart_Handle url,
+ Dart_Handle import_url_map) {
if (tag == kCanonicalizeUrl) {
return url;
}
@@ -3576,41 +3579,42 @@
Dart_Handle source = Dart_NewString(kScriptChars);
Dart_Handle error = Dart_Error("incoming error");
Dart_Handle result;
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(Dart_Null(), source);
+ result = Dart_LoadScript(Dart_Null(), source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.",
Dart_GetError(result));
- result = Dart_LoadScript(Dart_True(), source);
+ result = Dart_LoadScript(Dart_True(), source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.",
Dart_GetError(result));
- result = Dart_LoadScript(error, source);
+ result = Dart_LoadScript(error, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
- result = Dart_LoadScript(url, Dart_Null());
+ result = Dart_LoadScript(url, Dart_Null(), import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.",
Dart_GetError(result));
- result = Dart_LoadScript(url, Dart_True());
+ result = Dart_LoadScript(url, Dart_True(), import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ(
"Dart_LoadScript expects argument 'source' to be of type String.",
Dart_GetError(result));
- result = Dart_LoadScript(url, error);
+ result = Dart_LoadScript(url, error, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
// Load a script successfully.
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT_VALID(result);
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
@@ -3621,7 +3625,7 @@
EXPECT_EQ(12345, value);
// Further calls to LoadScript are errors.
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadScript: "
"A script has already been loaded from 'dart:test-lib'.",
@@ -3640,7 +3644,8 @@
static Dart_Handle import_library_handler(Dart_LibraryTag tag,
Dart_Handle library,
- Dart_Handle url) {
+ Dart_Handle url,
+ Dart_Handle import_url_map) {
if (tag == kCanonicalizeUrl) {
return url;
}
@@ -3691,9 +3696,7 @@
}
Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler);
EXPECT_VALID(result);
- result = Dart_SetImportMap(import_map);
- EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT(!Dart_IsError(result));
}
@@ -3706,9 +3709,10 @@
"}";
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT(strstr(Dart_GetError(result),
"import variable 'DEF' has not been defined"));
@@ -3730,9 +3734,7 @@
}
Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler);
EXPECT_VALID(result);
- result = Dart_SetImportMap(import_map);
- EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT(strstr(Dart_GetError(result), "'}' expected"));
}
@@ -3743,9 +3745,10 @@
")";
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
Dart_Handle result = Dart_SetLibraryTagHandler(import_library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
}
@@ -3762,14 +3765,15 @@
// Create a test library and Load up a test script in it.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
Dart_Handle result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
EXPECT_VALID(result);
url = Dart_NewString("library1.dart");
source = Dart_NewString(kLibrary1Chars);
- result = Dart_LoadLibrary(url, source);
+ result = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(result);
result = Dart_LookupLibrary(url);
@@ -3803,7 +3807,7 @@
"#library('library1_name');";
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
- Dart_Handle lib = Dart_LoadLibrary(url, source);
+ Dart_Handle lib = Dart_LoadLibrary(url, source, Dart_Null());
Dart_Handle error = Dart_Error("incoming error");
EXPECT_VALID(lib);
@@ -3841,12 +3845,13 @@
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
- Dart_Handle lib1 = Dart_LoadLibrary(url, source);
+ Dart_Handle import_map = Dart_NewList(0);
+ Dart_Handle lib1 = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(lib1);
url = Dart_NewString("library2_url");
source = Dart_NewString(kLibrary2Chars);
- Dart_Handle lib2 = Dart_LoadLibrary(url, source);
+ Dart_Handle lib2 = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(lib2);
result = Dart_LibraryImportLibrary(Dart_Null(), lib2);
@@ -3895,43 +3900,44 @@
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
+ Dart_Handle import_map = Dart_NewList(0);
- result = Dart_LoadLibrary(Dart_Null(), source);
+ result = Dart_LoadLibrary(Dart_Null(), source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.",
Dart_GetError(result));
- result = Dart_LoadLibrary(Dart_True(), source);
+ result = Dart_LoadLibrary(Dart_True(), source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.",
Dart_GetError(result));
- result = Dart_LoadLibrary(error, source);
+ result = Dart_LoadLibrary(error, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
- result = Dart_LoadLibrary(url, Dart_Null());
+ result = Dart_LoadLibrary(url, Dart_Null(), import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.",
Dart_GetError(result));
- result = Dart_LoadLibrary(url, Dart_True());
+ result = Dart_LoadLibrary(url, Dart_True(), import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ(
"Dart_LoadLibrary expects argument 'source' to be of type String.",
Dart_GetError(result));
- result = Dart_LoadLibrary(url, error);
+ result = Dart_LoadLibrary(url, error, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ("incoming error", Dart_GetError(result));
// Success.
- result = Dart_LoadLibrary(url, source);
+ result = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(result);
EXPECT(Dart_IsLibrary(result));
// Duplicate library load fails.
- result = Dart_LoadLibrary(url, source);
+ result = Dart_LoadLibrary(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT_STREQ(
"Dart_LoadLibrary: library 'library1_url' has already been loaded.",
@@ -3945,7 +3951,8 @@
")";
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
- Dart_Handle result = Dart_LoadLibrary(url, source);
+ Dart_Handle import_map = Dart_NewList(0);
+ Dart_Handle result = Dart_LoadLibrary(url, source, import_map);
EXPECT(Dart_IsError(result));
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
}
@@ -3964,7 +3971,8 @@
// Load up a library.
Dart_Handle url = Dart_NewString("library1_url");
Dart_Handle source = Dart_NewString(kLibrary1Chars);
- Dart_Handle lib = Dart_LoadLibrary(url, source);
+ Dart_Handle import_map = Dart_NewList(0);
+ Dart_Handle lib = Dart_LoadLibrary(url, source, import_map);
EXPECT_VALID(lib);
EXPECT(Dart_IsLibrary(lib));
@@ -4073,9 +4081,10 @@
// Load a test script.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- Dart_Handle lib = Dart_LoadScript(url, source);
+ Dart_Handle lib = Dart_LoadScript(url, source, import_map);
EXPECT_VALID(lib);
EXPECT(Dart_IsLibrary(lib));
Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Test"));
@@ -4156,15 +4165,15 @@
Dart_Handle source = Dart_NewString(kScriptChars);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, Dart_Null());
url = Dart_NewString("library1.dart");
source = Dart_NewString(kLibrary1Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, Dart_Null());
url = Dart_NewString("library2.dart");
source = Dart_NewString(kLibrary2Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, Dart_Null());
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
EXPECT(Dart_IsError(result));
@@ -4191,17 +4200,18 @@
// Create a test library and Load up a test script in it.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
url = Dart_NewString("library1.dart");
source = Dart_NewString(kLibrary1Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("library2.dart");
source = Dart_NewString(kLibrary2Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
EXPECT_VALID(result);
@@ -4225,17 +4235,18 @@
// Create a test library and Load up a test script in it.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
url = Dart_NewString("library2.dart");
source = Dart_NewString(kLibrary2Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("library1.dart");
source = Dart_NewString(kLibrary1Chars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
EXPECT(Dart_IsError(result));
@@ -4281,33 +4292,34 @@
// Create a test library and Load up a test script in it.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
url = Dart_NewString("libraryA.dart");
source = Dart_NewString(kLibraryAChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("libraryC.dart");
source = Dart_NewString(kLibraryCChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("libraryB.dart");
source = Dart_NewString(kLibraryBChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("libraryD.dart");
source = Dart_NewString(kLibraryDChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("libraryF.dart");
source = Dart_NewString(kLibraryFChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
url = Dart_NewString("libraryE.dart");
source = Dart_NewString(kLibraryEChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
EXPECT(Dart_IsError(result));
@@ -4334,13 +4346,14 @@
// Create a test library and Load up a test script in it.
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
result = Dart_SetLibraryTagHandler(library_handler);
EXPECT_VALID(result);
- result = Dart_LoadScript(url, source);
+ result = Dart_LoadScript(url, source, import_map);
url = Dart_NewString("lib.dart");
source = Dart_NewString(kLibraryChars);
- Dart_LoadLibrary(url, source);
+ Dart_LoadLibrary(url, source, import_map);
result = Dart_Invoke(result, Dart_NewString("main"), 0, NULL);
EXPECT_VALID(result);
@@ -4436,10 +4449,8 @@
}
-static bool RunLoopTestCallback(const char* script_name,
- const char* main,
- void* data,
- char** error) {
+static bool RunLoopTestCallback(const char* name_prefix,
+ void* data, char** error) {
const char* kScriptChars =
"#import('builtin');\n"
"#import('dart:isolate');\n"
@@ -4474,9 +4485,10 @@
Dart_EnterScope();
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
EXPECT_VALID(result);
- Dart_Handle lib = Dart_LoadScript(url, source);
+ Dart_Handle lib = Dart_LoadScript(url, source, import_map);
EXPECT_VALID(lib);
Dart_ExitScope();
return true;
@@ -4488,7 +4500,7 @@
bool throw_exception_parent) {
Dart_IsolateCreateCallback saved = Isolate::CreateCallback();
Isolate::SetCreateCallback(RunLoopTestCallback);
- RunLoopTestCallback(NULL, NULL, NULL, NULL);
+ RunLoopTestCallback(NULL, NULL, NULL);
Dart_EnterScope();
Dart_Handle lib = Dart_LookupLibrary(Dart_NewString(TestCase::url()));
@@ -4572,14 +4584,15 @@
{
sync->Enter();
char* error = NULL;
- shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error);
+ shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error);
EXPECT(shared_isolate != NULL);
Dart_EnterScope();
Dart_Handle url = Dart_NewString(TestCase::url());
Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle import_map = Dart_NewList(0);
Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
EXPECT_VALID(result);
- lib = Dart_LoadScript(url, source);
+ lib = Dart_LoadScript(url, source, import_map);
EXPECT_VALID(lib);
result = Dart_SetNativeResolver(lib, &IsolateInterruptTestNativeLookup);
DART_CHECK_VALID(result);
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698