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

Side by Side Diff: tests/compiler/dart2js/serialization/equivalence_test.dart

Issue 2004833003: Support multiple resolution inputs from command line. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix and check library separation 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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.serialization_test; 5 library dart2js.serialization_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import '../memory_compiler.dart'; 8 import '../memory_compiler.dart';
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:compiler/src/commandline_options.dart'; 10 import 'package:compiler/src/commandline_options.dart';
11 import 'package:compiler/src/common.dart';
11 import 'package:compiler/src/constants/constructors.dart'; 12 import 'package:compiler/src/constants/constructors.dart';
12 import 'package:compiler/src/compiler.dart'; 13 import 'package:compiler/src/compiler.dart';
13 import 'package:compiler/src/diagnostics/invariant.dart'; 14 import 'package:compiler/src/diagnostics/invariant.dart';
14 import 'package:compiler/src/elements/elements.dart'; 15 import 'package:compiler/src/elements/elements.dart';
15 import 'package:compiler/src/elements/visitor.dart'; 16 import 'package:compiler/src/elements/visitor.dart';
16 import 'package:compiler/src/ordered_typeset.dart'; 17 import 'package:compiler/src/ordered_typeset.dart';
17 import 'package:compiler/src/serialization/element_serialization.dart'; 18 import 'package:compiler/src/serialization/element_serialization.dart';
18 import 'package:compiler/src/serialization/equivalence.dart'; 19 import 'package:compiler/src/serialization/equivalence.dart';
19 import 'package:compiler/src/serialization/json_serializer.dart'; 20 import 'package:compiler/src/serialization/json_serializer.dart';
20 import 'package:compiler/src/serialization/serialization.dart'; 21 import 'package:compiler/src/serialization/serialization.dart';
22 import 'package:expect/expect.dart';
21 import 'test_helper.dart'; 23 import 'test_helper.dart';
22 24
23 main(List<String> arguments) { 25 main(List<String> arguments) {
24 // Ensure that we can print out constant expressions. 26 // Ensure that we can print out constant expressions.
25 DEBUG_MODE = true; 27 DEBUG_MODE = true;
26 28
27 Uri entryPoint; 29 Uri entryPoint;
28 String outPath; 30 String outPath;
29 bool prettyPrint = false; 31 bool prettyPrint = false;
30 for (String arg in arguments) { 32 for (String arg in arguments) {
(...skipping 13 matching lines...) Expand all
44 } 46 }
45 } 47 }
46 if (entryPoint == null) { 48 if (entryPoint == null) {
47 entryPoint = Uri.parse('dart:core'); 49 entryPoint = Uri.parse('dart:core');
48 } 50 }
49 asyncTest(() async { 51 asyncTest(() async {
50 CompilationResult result = await runCompiler( 52 CompilationResult result = await runCompiler(
51 entryPoint: entryPoint, options: [Flags.analyzeAll]); 53 entryPoint: entryPoint, options: [Flags.analyzeAll]);
52 Compiler compiler = result.compiler; 54 Compiler compiler = result.compiler;
53 testSerialization(compiler.libraryLoader.libraries, 55 testSerialization(compiler.libraryLoader.libraries,
56 compiler.reporter,
54 outPath: outPath, 57 outPath: outPath,
55 prettyPrint: prettyPrint); 58 prettyPrint: prettyPrint);
59 Expect.isFalse(compiler.reporter.hasReportedError,
60 "Unexpected errors occured.");
56 }); 61 });
57 } 62 }
58 63
59 void testSerialization(Iterable<LibraryElement> libraries1, 64 void testSerialization(
60 {String outPath, 65 Iterable<LibraryElement> libraries1,
61 bool prettyPrint}) { 66 DiagnosticReporter reporter,
67 {String outPath,
68 bool prettyPrint}) {
62 Serializer serializer = new Serializer(); 69 Serializer serializer = new Serializer();
63 for (LibraryElement library1 in libraries1) { 70 for (LibraryElement library1 in libraries1) {
64 serializer.serialize(library1); 71 serializer.serialize(library1);
65 } 72 }
66 String text = serializer.toText(const JsonSerializationEncoder()); 73 String text = serializer.toText(const JsonSerializationEncoder());
67 String outText = text; 74 String outText = text;
68 if (prettyPrint) { 75 if (prettyPrint) {
69 outText = serializer.prettyPrint(); 76 outText = serializer.prettyPrint();
70 } 77 }
71 if (outPath != null) { 78 if (outPath != null) {
72 new File(outPath).writeAsStringSync(outText); 79 new File(outPath).writeAsStringSync(outText);
73 } else if (prettyPrint) { 80 } else if (prettyPrint) {
74 print(outText); 81 print(outText);
75 } 82 }
76 83
77 Deserializer deserializer = new Deserializer.fromText( 84 Deserializer deserializer = new Deserializer.fromText(
78 new DeserializationContext(), 85 new DeserializationContext(reporter), Uri.parse('out1.data'),
79 text, const JsonSerializationDecoder()); 86 text, const JsonSerializationDecoder());
80 List<LibraryElement> libraries2 = <LibraryElement>[]; 87 List<LibraryElement> libraries2 = <LibraryElement>[];
81 for (LibraryElement library1 in libraries1) { 88 for (LibraryElement library1 in libraries1) {
82 LibraryElement library2 = 89 LibraryElement library2 =
83 deserializer.lookupLibrary(library1.canonicalUri); 90 deserializer.lookupLibrary(library1.canonicalUri);
84 if (library2 == null) { 91 if (library2 == null) {
85 throw new ArgumentError('No library ${library1.canonicalUri} found.'); 92 throw new ArgumentError('No library ${library1.canonicalUri} found.');
86 } 93 }
87 checkLibraryContent('library1', 'library2', 'library', library1, library2); 94 checkLibraryContent('library1', 'library2', 'library', library1, library2);
88 libraries2.add(library2); 95 libraries2.add(library2);
89 } 96 }
90 97
91 Serializer serializer2 = new Serializer(); 98 Serializer serializer2 = new Serializer();
92 for (LibraryElement library2 in libraries2) { 99 for (LibraryElement library2 in libraries2) {
93 serializer2.serialize(library2); 100 serializer2.serialize(library2);
94 } 101 }
95 String text2 = serializer2.toText(const JsonSerializationEncoder()); 102 String text2 = serializer2.toText(const JsonSerializationEncoder());
96 103
97 Deserializer deserializer3 = new Deserializer.fromText( 104 Deserializer deserializer3 = new Deserializer.fromText(
98 new DeserializationContext(), 105 new DeserializationContext(reporter), Uri.parse('out2.data'),
99 text2, const JsonSerializationDecoder()); 106 text2, const JsonSerializationDecoder());
100 for (LibraryElement library1 in libraries1) { 107 for (LibraryElement library1 in libraries1) {
101 LibraryElement library2 = 108 LibraryElement library2 =
102 deserializer.lookupLibrary(library1.canonicalUri); 109 deserializer.lookupLibrary(library1.canonicalUri);
103 if (library2 == null) { 110 if (library2 == null) {
104 throw new ArgumentError('No library ${library1.canonicalUri} found.'); 111 throw new ArgumentError('No library ${library1.canonicalUri} found.');
105 } 112 }
106 LibraryElement library3 = 113 LibraryElement library3 =
107 deserializer3.lookupLibrary(library1.canonicalUri); 114 deserializer3.lookupLibrary(library1.canonicalUri);
108 if (library3 == null) { 115 if (library3 == null) {
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { 701 void visitPrefixElement(PrefixElement element1, PrefixElement element2) {
695 check( 702 check(
696 element1, element2, 'isDeferred', 703 element1, element2, 'isDeferred',
697 element1.isDeferred, element2.isDeferred); 704 element1.isDeferred, element2.isDeferred);
698 checkElementIdentities( 705 checkElementIdentities(
699 element1, element2, 'importedLibrary', 706 element1, element2, 'importedLibrary',
700 element1.deferredImport, element2.deferredImport); 707 element1.deferredImport, element2.deferredImport);
701 // TODO(johnniwinther): Check members. 708 // TODO(johnniwinther): Check members.
702 } 709 }
703 } 710 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698