| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Partial test that the closed world computed from [WorldImpact]s derived from | 5 // Partial test that the closed world computed from [WorldImpact]s derived from |
| 6 // kernel is equivalent to the original computed from resolution. | 6 // kernel is equivalent to the original computed from resolution. |
| 7 library dart2js.kernel.closed_world2_test; | 7 library dart2js.kernel.closed_world2_test; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 import '../serialization/helper.dart'; | 48 import '../serialization/helper.dart'; |
| 49 import '../serialization/model_test_helper.dart'; | 49 import '../serialization/model_test_helper.dart'; |
| 50 import '../serialization/test_helper.dart'; | 50 import '../serialization/test_helper.dart'; |
| 51 | 51 |
| 52 import 'closed_world_test.dart' hide KernelWorkItemBuilder; | 52 import 'closed_world_test.dart' hide KernelWorkItemBuilder; |
| 53 import 'impact_test.dart'; | 53 import 'impact_test.dart'; |
| 54 | 54 |
| 55 const SOURCE = const { | 55 const SOURCE = const { |
| 56 'main.dart': ''' | 56 'main.dart': ''' |
| 57 import 'dart:html'; | 57 import 'dart:html'; |
| 58 import 'package:expect/expect.dart'; |
| 58 | 59 |
| 60 @NoInline() |
| 59 main() { | 61 main() { |
| 60 print('Hello World'); | 62 print('Hello World'); |
| 61 ''.contains; // Trigger member closurization. | 63 ''.contains; // Trigger member closurization. |
| 62 new Element.div(); | 64 new Element.div(); |
| 63 } | 65 } |
| 64 ''' | 66 ''' |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 main(List<String> args) { | 69 main(List<String> args) { |
| 68 asyncTest(() async { | 70 asyncTest(() async { |
| 69 await mainInternal(args); | 71 await mainInternal(args); |
| 70 }); | 72 }); |
| 71 } | 73 } |
| 72 | 74 |
| 73 Future mainInternal(List<String> args) async { | 75 Future mainInternal(List<String> args, |
| 76 {bool skipWarnings: false, bool skipErrors: false}) async { |
| 74 Arguments arguments = new Arguments.from(args); | 77 Arguments arguments = new Arguments.from(args); |
| 75 Uri entryPoint; | 78 Uri entryPoint; |
| 76 Map<String, String> memorySourceFiles; | 79 Map<String, String> memorySourceFiles; |
| 77 if (arguments.uri != null) { | 80 if (arguments.uri != null) { |
| 78 entryPoint = arguments.uri; | 81 entryPoint = arguments.uri; |
| 79 memorySourceFiles = const <String, String>{}; | 82 memorySourceFiles = const <String, String>{}; |
| 80 } else { | 83 } else { |
| 81 entryPoint = Uri.parse('memory:main.dart'); | 84 entryPoint = Uri.parse('memory:main.dart'); |
| 82 memorySourceFiles = SOURCE; | 85 memorySourceFiles = SOURCE; |
| 83 } | 86 } |
| 84 | 87 |
| 85 enableDebugMode(); | 88 enableDebugMode(); |
| 86 | 89 |
| 87 print('---- analyze-only ------------------------------------------------'); | 90 print('---- analyze-only ------------------------------------------------'); |
| 91 DiagnosticCollector collector = new DiagnosticCollector(); |
| 88 Compiler compiler1 = compilerFor( | 92 Compiler compiler1 = compilerFor( |
| 89 entryPoint: entryPoint, | 93 entryPoint: entryPoint, |
| 90 memorySourceFiles: memorySourceFiles, | 94 memorySourceFiles: memorySourceFiles, |
| 95 diagnosticHandler: collector, |
| 91 options: [Flags.analyzeOnly, Flags.enableAssertMessage]); | 96 options: [Flags.analyzeOnly, Flags.enableAssertMessage]); |
| 92 ElementResolutionWorldBuilder.useInstantiationMap = true; | 97 ElementResolutionWorldBuilder.useInstantiationMap = true; |
| 93 compiler1.resolution.retainCachesForTesting = true; | 98 compiler1.resolution.retainCachesForTesting = true; |
| 94 await compiler1.run(entryPoint); | 99 await compiler1.run(entryPoint); |
| 100 if (collector.errors.isNotEmpty && skipErrors) { |
| 101 print('Skipping due to errors.'); |
| 102 return; |
| 103 } |
| 104 if (collector.warnings.isNotEmpty && skipWarnings) { |
| 105 print('Skipping due to warnings.'); |
| 106 return; |
| 107 } |
| 95 Expect.isFalse(compiler1.compilationFailed); | 108 Expect.isFalse(compiler1.compilationFailed); |
| 96 ResolutionEnqueuer enqueuer1 = compiler1.enqueuer.resolution; | 109 ResolutionEnqueuer enqueuer1 = compiler1.enqueuer.resolution; |
| 97 BackendUsage backendUsage1 = compiler1.backend.backendUsage; | 110 BackendUsage backendUsage1 = compiler1.backend.backendUsage; |
| 98 ClosedWorld closedWorld1 = compiler1.resolutionWorldBuilder.closeWorld(); | 111 ClosedWorld closedWorld1 = compiler1.resolutionWorldBuilder.closeWorld(); |
| 99 | 112 |
| 100 print('---- analyze-all -------------------------------------------------'); | 113 print('---- analyze-all -------------------------------------------------'); |
| 101 Compiler compiler = compilerFor( | 114 Compiler compiler = compilerFor( |
| 102 entryPoint: entryPoint, | 115 entryPoint: entryPoint, |
| 103 memorySourceFiles: memorySourceFiles, | 116 memorySourceFiles: memorySourceFiles, |
| 104 options: [Flags.analyzeAll, Flags.useKernel, Flags.enableAssertMessage]); | 117 options: [Flags.analyzeAll, Flags.useKernel, Flags.enableAssertMessage]); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 294 |
| 282 MemoryDillLibraryLoaderTask(KernelToElementMap elementMap, | 295 MemoryDillLibraryLoaderTask(KernelToElementMap elementMap, |
| 283 DiagnosticReporter reporter, Measurer measurer, this.program) | 296 DiagnosticReporter reporter, Measurer measurer, this.program) |
| 284 : super(elementMap, null, null, reporter, measurer); | 297 : super(elementMap, null, null, reporter, measurer); |
| 285 | 298 |
| 286 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, | 299 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, |
| 287 {bool skipFileWithPartOfTag: false}) async { | 300 {bool skipFileWithPartOfTag: false}) async { |
| 288 return createLoadedLibraries(program); | 301 return createLoadedLibraries(program); |
| 289 } | 302 } |
| 290 } | 303 } |
| OLD | NEW |