mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Fix a set of tests that exercised the library Dart API functions in kernel mode.
Change-Id: Id7ac9166615d2b7de3604da555d9fc61563586af Reviewed-on: https://dart-review.googlesource.com/20340 Commit-Queue: Siva Annamalai <asiva@google.com> Reviewed-by: Siva Chandra <sivachandra@google.com>
This commit is contained in:
parent
58ffdbf5fc
commit
1c282f6482
5 changed files with 176 additions and 103 deletions
|
@ -246,13 +246,7 @@ cc/Mixin_PrivateSuperResolutionCrossLibraryShouldFail: Skip
|
|||
cc/CanonicalizationInScriptSnapshots: Fail
|
||||
cc/Class_ComputeEndTokenPos: Crash
|
||||
cc/DartAPI_CurrentStackTraceInfo: Fail
|
||||
cc/DartAPI_FieldAccess: Crash
|
||||
cc/DartAPI_ImplicitNativeFieldAccess: Crash
|
||||
cc/DartAPI_ImportLibrary2: Crash
|
||||
cc/DartAPI_ImportLibrary3: Crash
|
||||
cc/DartAPI_ImportLibrary4: Crash
|
||||
cc/DartAPI_ImportLibrary5: Crash
|
||||
cc/DartAPI_ImportLibraryWithPrefix: Crash
|
||||
cc/DartAPI_InjectNativeFields1: Skip
|
||||
cc/DartAPI_InjectNativeFields3: Crash
|
||||
cc/DartAPI_InjectNativeFields4: Crash
|
||||
|
@ -261,13 +255,7 @@ cc/DartAPI_Invoke_CrossLibrary: Crash
|
|||
cc/DartAPI_InvokeNoSuchMethod: Fail
|
||||
cc/DartAPI_IsolateShutdownRunDartCode: Skip # Flaky
|
||||
cc/DartAPI_LazyLoadDeoptimizes: Fail
|
||||
cc/DartAPI_LibraryGetClassNames: Crash
|
||||
cc/DartAPI_LibraryId: Crash
|
||||
cc/DartAPI_LibraryImportLibrary: Crash
|
||||
cc/DartAPI_LibraryName: Crash
|
||||
cc/DartAPI_LibraryUrl: Crash
|
||||
cc/DartAPI_LoadLibrary: Crash
|
||||
cc/DartAPI_LoadLibrary_CompileError: Crash
|
||||
cc/DartAPI_LoadLibraryPatch_Error1: Fail
|
||||
cc/DartAPI_LoadLibraryPatch_Error2: Fail
|
||||
cc/DartAPI_LoadLibraryPatch_Error3: Fail
|
||||
|
|
|
@ -5431,7 +5431,8 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
|
|||
Dart_Handle result;
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
if (I->use_dart_frontend()) {
|
||||
result = LoadKernelProgram(T, url_str, reinterpret_cast<void*>(source));
|
||||
void* kernel_pgm = reinterpret_cast<void*>(source);
|
||||
result = LoadKernelProgram(T, url_str, kernel_pgm);
|
||||
if (::Dart_IsError(result)) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -3735,11 +3735,10 @@ TEST_CASE(DartAPI_FieldAccess) {
|
|||
Dart_Handle name;
|
||||
|
||||
// Load imported lib.
|
||||
Dart_Handle url = NewString("library_url");
|
||||
Dart_Handle source = NewString(kImportedScriptChars);
|
||||
Dart_Handle imported_lib = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle prefix = Dart_EmptyString();
|
||||
Dart_Handle imported_lib =
|
||||
TestCase::LoadTestLibrary("library_url", kImportedScriptChars);
|
||||
EXPECT_VALID(imported_lib);
|
||||
Dart_Handle prefix = Dart_EmptyString();
|
||||
Dart_Handle result = Dart_LibraryImportLibrary(lib, imported_lib, prefix);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_FinalizeLoading(false);
|
||||
|
@ -5775,9 +5774,7 @@ TEST_CASE(DartAPI_LookupLibrary) {
|
|||
|
||||
TEST_CASE(DartAPI_LibraryName) {
|
||||
const char* kLibrary1Chars = "library library1_name;";
|
||||
Dart_Handle url = NewString("library1_url");
|
||||
Dart_Handle source = NewString(kLibrary1Chars);
|
||||
Dart_Handle lib = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
Dart_Handle error = Dart_NewApiError("incoming error");
|
||||
EXPECT_VALID(lib);
|
||||
|
||||
|
@ -5808,9 +5805,7 @@ TEST_CASE(DartAPI_LibraryName) {
|
|||
|
||||
TEST_CASE(DartAPI_LibraryId) {
|
||||
const char* kLibrary1Chars = "library library1_name;";
|
||||
Dart_Handle url = NewString("library1_url");
|
||||
Dart_Handle source = NewString(kLibrary1Chars);
|
||||
Dart_Handle lib = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
Dart_Handle error = Dart_NewApiError("incoming error");
|
||||
EXPECT_VALID(lib);
|
||||
intptr_t libraryId = -1;
|
||||
|
@ -5845,9 +5840,7 @@ TEST_CASE(DartAPI_LibraryId) {
|
|||
|
||||
TEST_CASE(DartAPI_LibraryUrl) {
|
||||
const char* kLibrary1Chars = "library library1_name;";
|
||||
Dart_Handle url = NewString("library1_url");
|
||||
Dart_Handle source = NewString(kLibrary1Chars);
|
||||
Dart_Handle lib = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
Dart_Handle error = Dart_NewApiError("incoming error");
|
||||
EXPECT_VALID(lib);
|
||||
|
||||
|
@ -5871,7 +5864,7 @@ TEST_CASE(DartAPI_LibraryUrl) {
|
|||
EXPECT(Dart_IsString(result));
|
||||
const char* cstr = NULL;
|
||||
EXPECT_VALID(Dart_StringToCString(result, &cstr));
|
||||
EXPECT_STREQ("library1_url", cstr);
|
||||
EXPECT_SUBSTRING("library1_url", cstr);
|
||||
}
|
||||
|
||||
TEST_CASE(DartAPI_LibraryGetClassNames) {
|
||||
|
@ -5888,9 +5881,7 @@ TEST_CASE(DartAPI_LibraryGetClassNames) {
|
|||
"_compare(String a, String b) => a.compareTo(b);\n"
|
||||
"sort(list) => list.sort(_compare);\n";
|
||||
|
||||
Dart_Handle url = NewString("library_url");
|
||||
Dart_Handle source = NewString(kLibraryChars);
|
||||
Dart_Handle lib = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib = TestCase::LoadTestLibrary("library_url", kLibraryChars);
|
||||
EXPECT_VALID(lib);
|
||||
Dart_Handle result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
|
@ -5987,14 +5978,10 @@ TEST_CASE(DartAPI_LibraryImportLibrary) {
|
|||
Dart_Handle error = Dart_NewApiError("incoming error");
|
||||
Dart_Handle result;
|
||||
|
||||
Dart_Handle url = NewString("library1_url");
|
||||
Dart_Handle source = NewString(kLibrary1Chars);
|
||||
Dart_Handle lib1 = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib1 = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
EXPECT_VALID(lib1);
|
||||
|
||||
url = NewString("library2_url");
|
||||
source = NewString(kLibrary2Chars);
|
||||
Dart_Handle lib2 = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle lib2 = TestCase::LoadTestLibrary("library2_url", kLibrary2Chars);
|
||||
EXPECT_VALID(lib2);
|
||||
|
||||
result = Dart_LibraryImportLibrary(Dart_Null(), lib2, Dart_Null());
|
||||
|
@ -6036,6 +6023,15 @@ TEST_CASE(DartAPI_LibraryImportLibrary) {
|
|||
}
|
||||
|
||||
TEST_CASE(DartAPI_ImportLibraryWithPrefix) {
|
||||
if (FLAG_use_dart_frontend) {
|
||||
// Not a valid test as it is not possible to load a script with unresolved
|
||||
// references.
|
||||
EXPECT(Dart_True());
|
||||
return;
|
||||
}
|
||||
|
||||
Dart_Handle lib2;
|
||||
Dart_Handle result;
|
||||
const char* kLibrary1Chars =
|
||||
"library library1_name;"
|
||||
"int bar() => 42;";
|
||||
|
@ -6050,12 +6046,12 @@ TEST_CASE(DartAPI_ImportLibraryWithPrefix) {
|
|||
"int foobar() => foo.bar();";
|
||||
Dart_Handle url2 = NewString("library2_url");
|
||||
Dart_Handle source2 = NewString(kLibrary2Chars);
|
||||
Dart_Handle lib2 = Dart_LoadLibrary(url2, Dart_Null(), source2, 0, 0);
|
||||
lib2 = Dart_LoadLibrary(url2, Dart_Null(), source2, 0, 0);
|
||||
EXPECT_VALID(lib2);
|
||||
EXPECT(Dart_IsLibrary(lib2));
|
||||
|
||||
Dart_Handle prefix = NewString("foo");
|
||||
Dart_Handle result = Dart_LibraryImportLibrary(lib2, lib1, prefix);
|
||||
result = Dart_LibraryImportLibrary(lib2, lib1, prefix);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
|
@ -6124,12 +6120,12 @@ TEST_CASE(DartAPI_LoadLibrary) {
|
|||
EXPECT_STREQ("incoming error", Dart_GetError(result));
|
||||
|
||||
// Success.
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
result = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
EXPECT_VALID(result);
|
||||
EXPECT(Dart_IsLibrary(result));
|
||||
|
||||
// Duplicate library load fails.
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
result = TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_STREQ(
|
||||
"Dart_LoadLibrary: library 'library1_url' has already been loaded.",
|
||||
|
@ -6140,11 +6136,15 @@ TEST_CASE(DartAPI_LoadLibrary_CompileError) {
|
|||
const char* kLibrary1Chars =
|
||||
"library library1_name;"
|
||||
")";
|
||||
Dart_Handle url = NewString("library1_url");
|
||||
Dart_Handle source = NewString(kLibrary1Chars);
|
||||
Dart_Handle result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_Handle result =
|
||||
TestCase::LoadTestLibrary("library1_url", kLibrary1Chars);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
|
||||
if (!FLAG_use_dart_frontend) {
|
||||
EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
|
||||
} else {
|
||||
EXPECT_SUBSTRING("Expected a declaration, but got ')'",
|
||||
Dart_GetError(result));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(DartAPI_LoadSource) {
|
||||
|
@ -6739,24 +6739,40 @@ TEST_CASE(DartAPI_ImportLibrary2) {
|
|||
"import 'library1_dart';\n"
|
||||
"var foo;\n";
|
||||
Dart_Handle result;
|
||||
Dart_Handle lib;
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
if (FLAG_use_dart_frontend) {
|
||||
Dart_SourceFile sourcefiles[] = {
|
||||
{RESOLVED_USER_TEST_URI, kScriptChars},
|
||||
{"file:///library1_dart", kLibrary1Chars},
|
||||
{"file:///library2_dart", kLibrary2Chars},
|
||||
};
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL,
|
||||
true);
|
||||
EXPECT_VALID(lib);
|
||||
} else {
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(lib);
|
||||
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
|
||||
Dart_FinalizeLoading(false);
|
||||
|
||||
result = Dart_Invoke(result, NewString("main"), 0, NULL);
|
||||
result = Dart_Invoke(lib, NewString("main"), 0, NULL);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
|
||||
|
@ -6764,8 +6780,8 @@ TEST_CASE(DartAPI_ImportLibrary2) {
|
|||
// an error if that name is referenced.
|
||||
TEST_CASE(DartAPI_ImportLibrary3) {
|
||||
const char* kScriptChars =
|
||||
"import 'library2_dart';\n"
|
||||
"import 'library1_dart';\n"
|
||||
"import 'file:///library2_dart';\n"
|
||||
"import 'file:///library1_dart';\n"
|
||||
"var foo_top = 10; // foo has dup def. So should be an error.\n"
|
||||
"main() { foo = 0; }\n";
|
||||
const char* kLibrary1Chars =
|
||||
|
@ -6775,26 +6791,40 @@ TEST_CASE(DartAPI_ImportLibrary3) {
|
|||
"library library2_dart;\n"
|
||||
"var foo;";
|
||||
Dart_Handle result;
|
||||
Dart_Handle lib;
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
if (FLAG_use_dart_frontend) {
|
||||
Dart_SourceFile sourcefiles[] = {
|
||||
{RESOLVED_USER_TEST_URI, kScriptChars},
|
||||
{"file:///library2_dart", kLibrary2Chars},
|
||||
{"file:///library1_dart", kLibrary1Chars},
|
||||
};
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL,
|
||||
true);
|
||||
EXPECT_VALID(lib);
|
||||
} else {
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(lib);
|
||||
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
|
||||
result = Dart_Invoke(result, NewString("main"), 0, NULL);
|
||||
result = Dart_Invoke(lib, NewString("main"), 0, NULL);
|
||||
EXPECT(Dart_IsError(result));
|
||||
EXPECT_SUBSTRING("NoSuchMethodError", Dart_GetError(result));
|
||||
}
|
||||
|
@ -6813,25 +6843,40 @@ TEST_CASE(DartAPI_ImportLibrary4) {
|
|||
"library library2_dart;\n"
|
||||
"var foo;";
|
||||
Dart_Handle result;
|
||||
Dart_Handle lib;
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
if (FLAG_use_dart_frontend) {
|
||||
Dart_SourceFile sourcefiles[] = {
|
||||
{RESOLVED_USER_TEST_URI, kScriptChars},
|
||||
{"file:///library2_dart", kLibrary2Chars},
|
||||
{"file:///library1_dart", kLibrary1Chars},
|
||||
};
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL,
|
||||
true);
|
||||
EXPECT_VALID(lib);
|
||||
} else {
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(lib);
|
||||
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
|
||||
url = NewString("library2_dart");
|
||||
source = NewString(kLibrary2Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
|
||||
url = NewString("library1_dart");
|
||||
source = NewString(kLibrary1Chars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_FinalizeLoading(false);
|
||||
|
||||
result = Dart_Invoke(result, NewString("main"), 0, NULL);
|
||||
result = Dart_Invoke(lib, NewString("main"), 0, NULL);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
|
||||
|
@ -6848,20 +6893,33 @@ TEST_CASE(DartAPI_ImportLibrary5) {
|
|||
" void set handler(void callback(List<int> x));\n"
|
||||
"}\n";
|
||||
Dart_Handle result;
|
||||
Dart_Handle lib;
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
if (FLAG_use_dart_frontend) {
|
||||
Dart_SourceFile sourcefiles[] = {
|
||||
{RESOLVED_USER_TEST_URI, kScriptChars},
|
||||
{"file:///lib.dart", kLibraryChars},
|
||||
};
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL,
|
||||
true);
|
||||
EXPECT_VALID(lib);
|
||||
} else {
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
result = Dart_SetLibraryTagHandler(library_handler);
|
||||
EXPECT_VALID(result);
|
||||
lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(lib);
|
||||
url = NewString("lib.dart");
|
||||
source = NewString(kLibraryChars);
|
||||
result = Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
result = Dart_FinalizeLoading(false);
|
||||
EXPECT_VALID(result);
|
||||
result = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
|
||||
|
||||
url = NewString("lib.dart");
|
||||
source = NewString(kLibraryChars);
|
||||
Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
Dart_FinalizeLoading(false);
|
||||
|
||||
result = Dart_Invoke(result, NewString("main"), 0, NULL);
|
||||
result = Dart_Invoke(lib, NewString("main"), 0, NULL);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -371,6 +371,31 @@ Dart_Handle TestCase::LoadTestScript(const char* script,
|
|||
}
|
||||
}
|
||||
|
||||
Dart_Handle TestCase::LoadTestLibrary(const char* lib_uri, const char* script) {
|
||||
if (FLAG_use_dart_frontend) {
|
||||
const char* prefixed_lib_uri =
|
||||
OS::SCreate(Thread::Current()->zone(), "file:///%s", lib_uri);
|
||||
Dart_SourceFile sourcefiles[] = {{prefixed_lib_uri, script}};
|
||||
Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler);
|
||||
EXPECT_VALID(result);
|
||||
void* kernel_pgm = NULL;
|
||||
int sourcefiles_count = sizeof(sourcefiles) / sizeof(Dart_SourceFile);
|
||||
OS::Print("Compiling %s %d\n", sourcefiles[0].uri, sourcefiles_count);
|
||||
char* error = TestCase::CompileTestScriptWithDFE(
|
||||
sourcefiles[0].uri, sourcefiles_count, sourcefiles, &kernel_pgm, false);
|
||||
if (error != NULL) {
|
||||
return Dart_NewApiError(error);
|
||||
}
|
||||
Dart_Handle url = NewString(prefixed_lib_uri);
|
||||
return Dart_LoadLibrary(url, Dart_Null(),
|
||||
reinterpret_cast<Dart_Handle>(kernel_pgm), 0, 0);
|
||||
} else {
|
||||
Dart_Handle url = NewString(lib_uri);
|
||||
Dart_Handle source = NewString(script);
|
||||
return Dart_LoadLibrary(url, Dart_Null(), source, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Dart_Handle TestCase::LoadTestScriptWithDFE(int sourcefiles_count,
|
||||
Dart_SourceFile sourcefiles[],
|
||||
Dart_NativeEntryResolver resolver,
|
||||
|
|
|
@ -300,6 +300,7 @@ class TestCase : TestCaseBase {
|
|||
Dart_NativeEntryResolver resolver,
|
||||
const char* lib_uri = USER_TEST_URI,
|
||||
bool finalize = true);
|
||||
static Dart_Handle LoadTestLibrary(const char* lib_uri, const char* script);
|
||||
static Dart_Handle LoadTestScriptWithDFE(
|
||||
int sourcefiles_count,
|
||||
Dart_SourceFile sourcefiles[],
|
||||
|
|
Loading…
Reference in a new issue