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

Unified Diff: tests/compiler/dart2js/serialization_resolved_ast_test.dart

Issue 1873573004: Serialize TreeElements (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Check only the last test to avoid timeout. Created 4 years, 8 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 | « tests/compiler/dart2js/serialization_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/serialization_resolved_ast_test.dart
diff --git a/tests/compiler/dart2js/serialization_resolved_ast_test.dart b/tests/compiler/dart2js/serialization_resolved_ast_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..af5d8a35c0835df87fedd9cebcc2253f007791e7
--- /dev/null
+++ b/tests/compiler/dart2js/serialization_resolved_ast_test.dart
@@ -0,0 +1,92 @@
+// 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.serialization_resolved_ast_test;
+
+import 'dart:async';
+import 'package:async_helper/async_helper.dart';
+import 'package:expect/expect.dart';
+import 'package:compiler/src/commandline_options.dart';
+import 'package:compiler/src/common/backend_api.dart';
+import 'package:compiler/src/common/names.dart';
+import 'package:compiler/src/compiler.dart';
+import 'package:compiler/src/elements/elements.dart';
+import 'package:compiler/src/filenames.dart';
+import 'package:compiler/src/serialization/equivalence.dart';
+import 'memory_compiler.dart';
+import 'serialization_helper.dart';
+import 'serialization_test_data.dart';
+import 'serialization_test_helper.dart';
+
+
+main(List<String> arguments) {
+ asyncTest(() async {
+ String serializedData = await serializeDartCore(serializeResolvedAst: true);
+ if (arguments.isNotEmpty) {
+ Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last));
+ await check(serializedData, entryPoint);
+ } else {
+ Uri entryPoint = Uri.parse('memory:main.dart');
+ // TODO(johnniwinther): Change to test all serialized resolved ast instead
+ // only those used in the test.
+ Test test = TESTS.last;
+ await check(serializedData, entryPoint, test.sourceFiles);
+ }
+ });
+}
+
+Future check(
+ String serializedData,
+ Uri entryPoint,
+ [Map<String, String> sourceFiles = const <String, String>{}]) async {
+
+ Compiler compilerNormal = compilerFor(
+ memorySourceFiles: sourceFiles,
+ options: [Flags.analyzeOnly]);
+ compilerNormal.resolution.retainCachesForTesting = true;
+ await compilerNormal.run(entryPoint);
+
+ Compiler compilerDeserialized = compilerFor(
+ memorySourceFiles: sourceFiles,
+ options: [Flags.analyzeOnly]);
+ compilerDeserialized.resolution.retainCachesForTesting = true;
+ deserialize(
+ compilerDeserialized, serializedData, deserializeResolvedAst: true);
+ await compilerDeserialized.run(entryPoint);
+
+ checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true);
+}
+
+void checkAllResolvedAsts(
+ Compiler compiler1,
+ Compiler compiler2,
+ {bool verbose: false}) {
+ checkLoadedLibraryMembers(
+ compiler1,
+ compiler2,
+ (Element member1) {
+ return compiler1.resolution.hasResolvedAst(member1);
+ },
+ checkResolvedAsts,
+ verbose: true);
+}
+
+
+/// Check equivalence of [impact1] and [impact2].
+void checkResolvedAsts(Compiler compiler1, Element member1,
+ Compiler compiler2, Element member2,
+ {bool verbose: false}) {
+ ResolvedAst resolvedAst1 = compiler1.resolution.getResolvedAst(member1);
+ ResolvedAst resolvedAst2 =
+ compiler2.serialization.deserializer.getResolvedAst(member2);
+
+ if (resolvedAst1 == null || resolvedAst2 == null) return;
+
+ if (verbose) {
+ print('Checking resolved asts for $member1 vs $member2');
+ }
+
+ testResolvedAstEquivalence(
+ resolvedAst1, resolvedAst2, const CheckStrategy());
+}
« no previous file with comments | « tests/compiler/dart2js/serialization_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698