OLD | NEW |
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/common.dart'; |
12 import 'package:compiler/src/common/resolution.dart'; | 12 import 'package:compiler/src/common/resolution.dart'; |
13 import 'package:compiler/src/constants/constructors.dart'; | 13 import 'package:compiler/src/constants/constructors.dart'; |
14 import 'package:compiler/src/compiler.dart'; | 14 import 'package:compiler/src/compiler.dart'; |
15 import 'package:compiler/src/diagnostics/invariant.dart'; | 15 import 'package:compiler/src/diagnostics/invariant.dart'; |
16 import 'package:compiler/src/elements/elements.dart'; | 16 import 'package:compiler/src/elements/elements.dart'; |
17 import 'package:compiler/src/elements/visitor.dart'; | 17 import 'package:compiler/src/elements/visitor.dart'; |
| 18 import 'package:compiler/src/filenames.dart'; |
18 import 'package:compiler/src/library_loader.dart'; | 19 import 'package:compiler/src/library_loader.dart'; |
19 import 'package:compiler/src/ordered_typeset.dart'; | 20 import 'package:compiler/src/ordered_typeset.dart'; |
20 import 'package:compiler/src/serialization/element_serialization.dart'; | 21 import 'package:compiler/src/serialization/element_serialization.dart'; |
21 import 'package:compiler/src/serialization/equivalence.dart'; | 22 import 'package:compiler/src/serialization/equivalence.dart'; |
22 import 'package:compiler/src/serialization/json_serializer.dart'; | 23 import 'package:compiler/src/serialization/json_serializer.dart'; |
23 import 'package:compiler/src/serialization/serialization.dart'; | 24 import 'package:compiler/src/serialization/serialization.dart'; |
24 import 'package:expect/expect.dart'; | 25 import 'package:expect/expect.dart'; |
25 import 'test_helper.dart'; | 26 import 'test_helper.dart'; |
26 | 27 |
| 28 const TEST_SOURCES = const <String, String>{ |
| 29 'main.dart': ''' |
| 30 import 'a.dart' deferred as a; |
| 31 ''', |
| 32 'a.dart': ''' |
| 33 ''', |
| 34 }; |
| 35 |
27 main(List<String> arguments) { | 36 main(List<String> arguments) { |
28 // Ensure that we can print out constant expressions. | 37 // Ensure that we can print out constant expressions. |
29 DEBUG_MODE = true; | 38 DEBUG_MODE = true; |
30 | 39 |
31 Uri entryPoint; | 40 Uri entryPoint; |
32 String outPath; | 41 String outPath; |
33 bool prettyPrint = false; | 42 bool prettyPrint = false; |
34 for (String arg in arguments) { | 43 for (String arg in arguments) { |
35 if (arg.startsWith('--')) { | 44 if (arg.startsWith('--')) { |
36 if (arg.startsWith('--out=')) { | 45 if (arg.startsWith('--out=')) { |
37 outPath = arg.substring('--out='.length); | 46 outPath = arg.substring('--out='.length); |
38 } else if (arg == '--pretty-print') { | 47 } else if (arg == '--pretty-print') { |
39 prettyPrint = true; | 48 prettyPrint = true; |
40 } else { | 49 } else { |
41 print("Unknown option $arg"); | 50 print("Unknown option $arg"); |
42 } | 51 } |
43 } else { | 52 } else { |
44 if (entryPoint != null) { | 53 if (entryPoint != null) { |
45 print("Multiple entrypoints is not supported."); | 54 print("Multiple entrypoints is not supported."); |
46 } | 55 } |
47 entryPoint = Uri.parse(arg); | 56 entryPoint = Uri.base.resolve(nativeToUriPath(arg)); |
48 } | 57 } |
49 } | 58 } |
| 59 Map<String, String> sourceFiles = const <String, String>{}; |
50 if (entryPoint == null) { | 60 if (entryPoint == null) { |
51 entryPoint = Uri.parse('dart:core'); | 61 entryPoint = Uri.parse('memory:main.dart'); |
| 62 sourceFiles = TEST_SOURCES; |
52 } | 63 } |
53 asyncTest(() async { | 64 asyncTest(() async { |
54 CompilationResult result = await runCompiler( | 65 CompilationResult result = await runCompiler( |
55 entryPoint: entryPoint, options: [Flags.analyzeAll]); | 66 memorySourceFiles: sourceFiles, |
| 67 entryPoint: entryPoint, |
| 68 options: [Flags.analyzeAll]); |
56 Compiler compiler = result.compiler; | 69 Compiler compiler = result.compiler; |
57 testSerialization( | 70 testSerialization( |
58 compiler.libraryLoader.libraries, | 71 compiler.libraryLoader.libraries, |
59 compiler.reporter, | 72 compiler.reporter, |
60 compiler.resolution, | 73 compiler.resolution, |
61 compiler.libraryLoader, | 74 compiler.libraryLoader, |
62 outPath: outPath, | 75 outPath: outPath, |
63 prettyPrint: prettyPrint); | 76 prettyPrint: prettyPrint); |
64 Expect.isFalse(compiler.reporter.hasReportedError, | 77 Expect.isFalse(compiler.reporter.hasReportedError, |
65 "Unexpected errors occured."); | 78 "Unexpected errors occured."); |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 element1, element2, 'importedLibrary', | 804 element1, element2, 'importedLibrary', |
792 element1.exportedLibrary, element2.exportedLibrary); | 805 element1.exportedLibrary, element2.exportedLibrary); |
793 } | 806 } |
794 | 807 |
795 @override | 808 @override |
796 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { | 809 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { |
797 check( | 810 check( |
798 element1, element2, 'isDeferred', | 811 element1, element2, 'isDeferred', |
799 element1.isDeferred, element2.isDeferred); | 812 element1.isDeferred, element2.isDeferred); |
800 checkElementIdentities( | 813 checkElementIdentities( |
801 element1, element2, 'importedLibrary', | 814 element1, element2, 'deferredImport', |
802 element1.deferredImport, element2.deferredImport); | 815 element1.deferredImport, element2.deferredImport); |
| 816 if (element1.isDeferred) { |
| 817 checkElementProperties(element1, element2, |
| 818 'loadLibrary', element1.loadLibrary, element2.loadLibrary); |
| 819 } |
803 // TODO(johnniwinther): Check members. | 820 // TODO(johnniwinther): Check members. |
804 } | 821 } |
805 } | 822 } |
OLD | NEW |