OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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_resolved_ast_test; | 5 library dart2js.serialization_resolved_ast_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
11 import 'package:compiler/src/elements/elements.dart'; | 11 import 'package:compiler/src/elements/elements.dart'; |
12 import 'package:compiler/src/filenames.dart'; | 12 import 'package:compiler/src/filenames.dart'; |
13 import 'package:compiler/src/serialization/equivalence.dart'; | 13 import 'package:compiler/src/serialization/equivalence.dart'; |
14 import '../memory_compiler.dart'; | 14 import '../memory_compiler.dart'; |
15 import 'helper.dart'; | 15 import 'helper.dart'; |
16 import 'test_data.dart'; | 16 import 'test_data.dart'; |
17 import 'test_helper.dart'; | 17 import 'test_helper.dart'; |
18 | 18 |
19 | |
20 main(List<String> args) { | 19 main(List<String> args) { |
21 Arguments arguments = new Arguments.from(args); | 20 Arguments arguments = new Arguments.from(args); |
22 asyncTest(() async { | 21 asyncTest(() async { |
23 SerializedData serializedData = | 22 SerializedData serializedData = |
24 await serializeDartCore(arguments: arguments); | 23 await serializeDartCore(arguments: arguments); |
25 if (arguments.filename != null) { | 24 if (arguments.filename != null) { |
26 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 25 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
27 await check(serializedData, entryPoint); | 26 await check(serializedData, entryPoint); |
28 } else { | 27 } else { |
29 Uri entryPoint = Uri.parse('memory:main.dart'); | 28 Uri entryPoint = Uri.parse('memory:main.dart'); |
30 // TODO(johnniwinther): Change to test all serialized resolved ast instead | 29 // TODO(johnniwinther): Change to test all serialized resolved ast instead |
31 // only those used in the test. | 30 // only those used in the test. |
32 Test test = TESTS.first; | 31 Test test = TESTS.first; |
33 await check(serializedData, entryPoint, test.sourceFiles); | 32 await check(serializedData, entryPoint, test.sourceFiles); |
34 } | 33 } |
35 }); | 34 }); |
36 } | 35 } |
37 | 36 |
38 Future check( | 37 Future check(SerializedData serializedData, Uri entryPoint, |
39 SerializedData serializedData, | 38 [Map<String, String> sourceFiles = const <String, String>{}]) async { |
40 Uri entryPoint, | 39 Compiler compilerNormal = |
41 [Map<String, String> sourceFiles = const <String, String>{}]) async { | 40 compilerFor(memorySourceFiles: sourceFiles, options: [Flags.analyzeAll]); |
42 | |
43 Compiler compilerNormal = compilerFor( | |
44 memorySourceFiles: sourceFiles, | |
45 options: [Flags.analyzeAll]); | |
46 compilerNormal.resolution.retainCachesForTesting = true; | 41 compilerNormal.resolution.retainCachesForTesting = true; |
47 await compilerNormal.run(entryPoint); | 42 await compilerNormal.run(entryPoint); |
48 | 43 |
49 Compiler compilerDeserialized = compilerFor( | 44 Compiler compilerDeserialized = compilerFor( |
50 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), | 45 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), |
51 resolutionInputs: serializedData.toUris(), | 46 resolutionInputs: serializedData.toUris(), |
52 options: [Flags.analyzeAll]); | 47 options: [Flags.analyzeAll]); |
53 compilerDeserialized.resolution.retainCachesForTesting = true; | 48 compilerDeserialized.resolution.retainCachesForTesting = true; |
54 await compilerDeserialized.run(entryPoint); | 49 await compilerDeserialized.run(entryPoint); |
55 | 50 |
56 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); | 51 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); |
57 } | 52 } |
OLD | NEW |