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

Unified Diff: tests/compiler/dart2js/serialization/reserialization_test.dart

Issue 2088233003: Serialize erroneous element and more (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
Index: tests/compiler/dart2js/serialization/reserialization_test.dart
diff --git a/tests/compiler/dart2js/serialization/reserialization_test.dart b/tests/compiler/dart2js/serialization/reserialization_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1b5ed6ce646110ac38be5bbc1c3ac975c25475e8
--- /dev/null
+++ b/tests/compiler/dart2js/serialization/reserialization_test.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+library dart2js.reserialization_test;
+
+import 'dart:async';
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/diagnostics/invariant.dart';
+import 'package:compiler/src/elements/elements.dart';
+import 'package:expect/expect.dart';
+import 'helper.dart';
+import 'test_helper.dart';
+import 'equivalence_test.dart';
+
+main(List<String> arguments) {
+ // Ensure that we can print out constant expressions.
+ DEBUG_MODE = true;
+
+ Uri entryPoint;
+ String outPath;
+ bool prettyPrint = false;
Harry Terkelsen 2016/06/23 23:13:25 prettyPrint is not used
+ for (String arg in arguments) {
+ if (arg.startsWith('--')) {
+ if (arg.startsWith('--out=')) {
+ outPath = arg.substring('--out='.length);
+ } else if (arg == '--pretty-print') {
+ prettyPrint = true;
+ } else {
+ print("Unknown option $arg");
+ }
+ } else {
+ if (entryPoint != null) {
+ print("Multiple entrypoints is not supported.");
+ }
+ entryPoint = Uri.parse(arg);
+ }
+ }
+ if (entryPoint == null) {
+ entryPoint = Uri.parse('dart:core');
+ }
+ asyncTest(() async {
+ await testReserialization(entryPoint);
+ });
+}
+
+Future testReserialization(Uri entryPoint) async {
+ SerializationResult result1 = await serialize(entryPoint);
+ Compiler compiler1 = result1.compiler;
+ SerializedData serializedData1 = result1.serializedData;
+ Iterable<LibraryElement> libraries1 = compiler1.libraryLoader.libraries;
+
+ SerializationResult result2 = await serialize(entryPoint,
+ memorySourceFiles: serializedData1.toMemorySourceFiles(),
+ resolutionInputs: serializedData1.toUris());
+ Compiler compiler2 = result2.compiler;
+ SerializedData serializedData2 = result2.serializedData;
+ Iterable<LibraryElement> libraries2 = compiler2.libraryLoader.libraries;
+
+ SerializationResult result3 = await serialize(entryPoint,
+ memorySourceFiles: serializedData2.toMemorySourceFiles(),
+ resolutionInputs: serializedData2.toUris());
+ Compiler compiler3 = result3.compiler;
+ Iterable<LibraryElement> libraries3 = compiler3.libraryLoader.libraries;
+
+ for (LibraryElement library1 in libraries1) {
+ LibraryElement library2 = libraries2.firstWhere((LibraryElement library2) {
+ return library2.canonicalUri == library1.canonicalUri;
+ });
+ Expect.isNotNull(library2,
+ "No library found for ${library1.canonicalUri}.");
+ checkLibraryContent('library1', 'library2', 'library', library1, library2);
+
+ LibraryElement library3 = libraries3.firstWhere((LibraryElement library3) {
+ return library3.canonicalUri == library1.canonicalUri;
+ });
+ Expect.isNotNull(library3,
+ "No library found for ${library1.canonicalUri}.");
+ checkLibraryContent('library1', 'library3', 'library', library1, library3);
+ }
+
+ checkAllResolvedAsts(compiler1, compiler2);
+ checkAllResolvedAsts(compiler1, compiler3);
+
+ checkAllImpacts(compiler1, compiler2);
+ checkAllImpacts(compiler1, compiler3);
+
+ //Expect.equals(serializedData1.data, serializedData2.data);
Harry Terkelsen 2016/06/23 23:13:25 either remove or uncomment
+}

Powered by Google App Engine
This is Rietveld 408576698