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

Unified Diff: vm/snapshot_test.cc

Issue 9314048: Fix for issue 1456 - register libraries read from a partial snapshot (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 11 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 | « vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/snapshot_test.cc
===================================================================
--- vm/snapshot_test.cc (revision 3801)
+++ vm/snapshot_test.cc (working copy)
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#include "include/dart_debugger_api.h"
#include "platform/assert.h"
#include "vm/bigint_operations.h"
#include "vm/class_finalizer.h"
@@ -544,6 +545,13 @@
UNIT_TEST_CASE(ScriptSnapshot) {
+ const char* kLibScriptChars =
+ "#library('dart:import-lib');"
+ "class LibFields {"
+ " LibFields(int i, int j) : fld1 = i, fld2 = j {}"
+ " int fld1;"
+ " final int fld2;"
+ "}";
const char* kScriptChars =
"class Fields {"
" Fields(int i, int j) : fld1 = i, fld2 = j {}"
@@ -580,6 +588,8 @@
intptr_t size;
uint8_t* full_snapshot = NULL;
uint8_t* script_snapshot = NULL;
+ intptr_t expected_num_libs;
+ intptr_t actual_num_libs;
{
// Start an Isolate, and create a full snapshot of it.
@@ -600,9 +610,21 @@
TestCase::CreateTestIsolateFromSnapshot(full_snapshot);
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
+ // Load the library.
+ Dart_Handle import_lib = Dart_LoadLibrary(Dart_NewString("dart:import-lib"),
+ Dart_NewString(kLibScriptChars));
+ EXPECT_VALID(import_lib);
+
// Create a test library and Load up a test script in it.
TestCase::LoadTestScript(kScriptChars, NULL);
+ EXPECT_VALID(Dart_LibraryImportLibrary(TestCase::lib(), import_lib));
+
+ // Get list of library URLs loaded and save the count.
+ Dart_Handle libs = Dart_GetLibraryURLs();
+ EXPECT(Dart_IsList(libs));
+ Dart_ListLength(libs, &expected_num_libs);
+
// Write out the script snapshot.
result = Dart_CreateScriptSnapshot(&buffer, &size);
EXPECT_VALID(result);
@@ -623,6 +645,13 @@
result = Dart_LoadScriptFromSnapshot(script_snapshot);
EXPECT_VALID(result);
+ // Get list of library URLs loaded and compare with expected count.
+ Dart_Handle libs = Dart_GetLibraryURLs();
+ EXPECT(Dart_IsList(libs));
+ Dart_ListLength(libs, &actual_num_libs);
+
+ EXPECT_EQ(expected_num_libs, actual_num_libs);
+
// Invoke a function which returns an object.
result = Dart_InvokeStatic(result,
Dart_NewString("FieldsTest"),
« no previous file with comments | « vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698