| Index: runtime/vm/snapshot_test.cc
|
| diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
|
| index 6707566f534756675fd1bd4f27eabab5aa754b5a..5c9a28a5d3c739105a5d6abe4595042a78dbbbd6 100644
|
| --- a/runtime/vm/snapshot_test.cc
|
| +++ b/runtime/vm/snapshot_test.cc
|
| @@ -1253,6 +1253,8 @@ UNIT_TEST_CASE(ScriptSnapshot) {
|
| }
|
|
|
| FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
|
| +
|
| + // Test for Dart_CreateScriptSnapshot.
|
| {
|
| // Create an Isolate using the full snapshot, load a script and create
|
| // a script snapshot of the script.
|
| @@ -1310,8 +1312,50 @@ UNIT_TEST_CASE(ScriptSnapshot) {
|
| result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
|
| EXPECT_VALID(result);
|
| Dart_ExitScope();
|
| + Dart_ShutdownIsolate();
|
| + }
|
| + free(script_snapshot);
|
| +
|
| + // Test for Dart_CreateLibrarySnapshot.
|
| + {
|
| + // Create an Isolate using the full snapshot, load a script and create
|
| + // a script snapshot of the script.
|
| + TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
|
| + Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
| +
|
| + // Load the library.
|
| + Dart_Handle lib = Dart_LoadLibrary(NewString("dart_lib"),
|
| + NewString(kScriptChars),
|
| + 0, 0);
|
| + EXPECT_VALID(lib);
|
| +
|
| + // Write out the script snapshot.
|
| + result = Dart_CreateLibrarySnapshot(lib, &buffer, &size);
|
| + EXPECT_VALID(result);
|
| + script_snapshot = reinterpret_cast<uint8_t*>(malloc(size));
|
| + memmove(script_snapshot, buffer, size);
|
| + Dart_ExitScope();
|
| + Dart_ShutdownIsolate();
|
| + }
|
| +
|
| + {
|
| + // Now Create an Isolate using the full snapshot and load the
|
| + // script snapshot created above and execute it.
|
| + TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
|
| + Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
| +
|
| + // Load the test library from the snapshot.
|
| + EXPECT(script_snapshot != NULL);
|
| + result = Dart_LoadScriptFromSnapshot(script_snapshot, size);
|
| + EXPECT_VALID(result);
|
| +
|
| + // Invoke a function which returns an object.
|
| + Dart_Handle cls = Dart_GetClass(result, NewString("FieldsTest"));
|
| + result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
|
| + EXPECT_VALID(result);
|
| + Dart_ExitScope();
|
| + Dart_ShutdownIsolate();
|
| }
|
| - Dart_ShutdownIsolate();
|
| free(full_snapshot);
|
| free(script_snapshot);
|
| }
|
|
|