OLD | NEW |
(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> args) { |
| 18 // Ensure that we can print out constant expressions. |
| 19 DEBUG_MODE = true; |
| 20 |
| 21 Arguments arguments = new Arguments.from(args); |
| 22 Uri entryPoint; |
| 23 if (arguments.filename != null) { |
| 24 entryPoint = Uri.parse(arguments.filename); |
| 25 } else { |
| 26 entryPoint = Uri.parse('dart:core'); |
| 27 } |
| 28 asyncTest(() async { |
| 29 await testReserialization(entryPoint); |
| 30 }); |
| 31 } |
| 32 |
| 33 Future testReserialization(Uri entryPoint) async { |
| 34 SerializationResult result1 = await serialize(entryPoint); |
| 35 Compiler compiler1 = result1.compiler; |
| 36 SerializedData serializedData1 = result1.serializedData; |
| 37 Iterable<LibraryElement> libraries1 = compiler1.libraryLoader.libraries; |
| 38 |
| 39 SerializationResult result2 = await serialize(entryPoint, |
| 40 memorySourceFiles: serializedData1.toMemorySourceFiles(), |
| 41 resolutionInputs: serializedData1.toUris()); |
| 42 Compiler compiler2 = result2.compiler; |
| 43 SerializedData serializedData2 = result2.serializedData; |
| 44 Iterable<LibraryElement> libraries2 = compiler2.libraryLoader.libraries; |
| 45 |
| 46 SerializationResult result3 = await serialize(entryPoint, |
| 47 memorySourceFiles: serializedData2.toMemorySourceFiles(), |
| 48 resolutionInputs: serializedData2.toUris()); |
| 49 Compiler compiler3 = result3.compiler; |
| 50 Iterable<LibraryElement> libraries3 = compiler3.libraryLoader.libraries; |
| 51 |
| 52 for (LibraryElement library1 in libraries1) { |
| 53 LibraryElement library2 = libraries2.firstWhere((LibraryElement library2) { |
| 54 return library2.canonicalUri == library1.canonicalUri; |
| 55 }); |
| 56 Expect.isNotNull(library2, |
| 57 "No library found for ${library1.canonicalUri}."); |
| 58 checkLibraryContent('library1', 'library2', 'library', library1, library2); |
| 59 |
| 60 LibraryElement library3 = libraries3.firstWhere((LibraryElement library3) { |
| 61 return library3.canonicalUri == library1.canonicalUri; |
| 62 }); |
| 63 Expect.isNotNull(library3, |
| 64 "No library found for ${library1.canonicalUri}."); |
| 65 checkLibraryContent('library1', 'library3', 'library', library1, library3); |
| 66 } |
| 67 |
| 68 checkAllResolvedAsts(compiler1, compiler2); |
| 69 checkAllResolvedAsts(compiler1, compiler3); |
| 70 |
| 71 checkAllImpacts(compiler1, compiler2); |
| 72 checkAllImpacts(compiler1, compiler3); |
| 73 } |
OLD | NEW |