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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart2js.reserialization_test;
6
7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart';
9 import 'package:compiler/src/compiler.dart';
10 import 'package:compiler/src/diagnostics/invariant.dart';
11 import 'package:compiler/src/elements/elements.dart';
12 import 'package:expect/expect.dart';
13 import 'helper.dart';
14 import 'test_helper.dart';
15 import 'equivalence_test.dart';
16
17 main(List<String> arguments) {
18 // Ensure that we can print out constant expressions.
19 DEBUG_MODE = true;
20
21 Uri entryPoint;
22 String outPath;
23 bool prettyPrint = false;
Harry Terkelsen 2016/06/23 23:13:25 prettyPrint is not used
24 for (String arg in arguments) {
25 if (arg.startsWith('--')) {
26 if (arg.startsWith('--out=')) {
27 outPath = arg.substring('--out='.length);
28 } else if (arg == '--pretty-print') {
29 prettyPrint = true;
30 } else {
31 print("Unknown option $arg");
32 }
33 } else {
34 if (entryPoint != null) {
35 print("Multiple entrypoints is not supported.");
36 }
37 entryPoint = Uri.parse(arg);
38 }
39 }
40 if (entryPoint == null) {
41 entryPoint = Uri.parse('dart:core');
42 }
43 asyncTest(() async {
44 await testReserialization(entryPoint);
45 });
46 }
47
48 Future testReserialization(Uri entryPoint) async {
49 SerializationResult result1 = await serialize(entryPoint);
50 Compiler compiler1 = result1.compiler;
51 SerializedData serializedData1 = result1.serializedData;
52 Iterable<LibraryElement> libraries1 = compiler1.libraryLoader.libraries;
53
54 SerializationResult result2 = await serialize(entryPoint,
55 memorySourceFiles: serializedData1.toMemorySourceFiles(),
56 resolutionInputs: serializedData1.toUris());
57 Compiler compiler2 = result2.compiler;
58 SerializedData serializedData2 = result2.serializedData;
59 Iterable<LibraryElement> libraries2 = compiler2.libraryLoader.libraries;
60
61 SerializationResult result3 = await serialize(entryPoint,
62 memorySourceFiles: serializedData2.toMemorySourceFiles(),
63 resolutionInputs: serializedData2.toUris());
64 Compiler compiler3 = result3.compiler;
65 Iterable<LibraryElement> libraries3 = compiler3.libraryLoader.libraries;
66
67 for (LibraryElement library1 in libraries1) {
68 LibraryElement library2 = libraries2.firstWhere((LibraryElement library2) {
69 return library2.canonicalUri == library1.canonicalUri;
70 });
71 Expect.isNotNull(library2,
72 "No library found for ${library1.canonicalUri}.");
73 checkLibraryContent('library1', 'library2', 'library', library1, library2);
74
75 LibraryElement library3 = libraries3.firstWhere((LibraryElement library3) {
76 return library3.canonicalUri == library1.canonicalUri;
77 });
78 Expect.isNotNull(library3,
79 "No library found for ${library1.canonicalUri}.");
80 checkLibraryContent('library1', 'library3', 'library', library1, library3);
81 }
82
83 checkAllResolvedAsts(compiler1, compiler2);
84 checkAllResolvedAsts(compiler1, compiler3);
85
86 checkAllImpacts(compiler1, compiler2);
87 checkAllImpacts(compiler1, compiler3);
88
89 //Expect.equals(serializedData1.data, serializedData2.data);
Harry Terkelsen 2016/06/23 23:13:25 either remove or uncomment
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698