OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Test that the additional runtime type support is output to the right | 5 // Test that the additional runtime type support is output to the right |
6 // Files when using deferred loading. | 6 // Files when using deferred loading. |
7 | 7 |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:compiler/compiler_new.dart'; | 9 import 'package:compiler/compiler_new.dart'; |
10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
11 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
12 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
13 import 'output_collector.dart'; | 13 import 'output_collector.dart'; |
14 | 14 |
15 void main() { | 15 void main() { |
16 OutputCollector collector = new OutputCollector(); | 16 OutputCollector collector = new OutputCollector(); |
17 asyncTest(() async { | 17 asyncTest(() async { |
18 CompilationResult result = await runCompiler( | 18 CompilationResult result = await runCompiler( |
19 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector); | 19 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector); |
20 Compiler compiler = result.compiler; | 20 Compiler compiler = result.compiler; |
21 lookupLibrary(name) { | 21 lookupLibrary(name) { |
22 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); | 22 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); |
23 } | 23 } |
24 | 24 |
25 var main = compiler.mainFunction; | 25 var main = compiler.frontendStrategy.elementEnvironment.mainFunction; |
26 Expect.isNotNull(main, "Could not find 'main'"); | 26 Expect.isNotNull(main, "Could not find 'main'"); |
27 compiler.deferredLoadTask.onResolutionComplete( | 27 compiler.deferredLoadTask.onResolutionComplete( |
28 main, compiler.resolutionWorldBuilder.closedWorldForTesting); | 28 main, compiler.resolutionWorldBuilder.closedWorldForTesting); |
29 | 29 |
30 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 30 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
31 | 31 |
32 var lib1 = lookupLibrary("memory:lib1.dart"); | 32 var lib1 = lookupLibrary("memory:lib1.dart"); |
33 var foo1 = lib1.find("finalVar"); | 33 var foo1 = lib1.find("finalVar"); |
34 var ou_lib1 = outputUnitForElement(foo1); | 34 var ou_lib1 = outputUnitForElement(foo1); |
35 | 35 |
(...skipping 25 matching lines...) Expand all Loading... |
61 print(lib1.globalVar); | 61 print(lib1.globalVar); |
62 }); | 62 }); |
63 } | 63 } |
64 """, | 64 """, |
65 "lib1.dart": """ | 65 "lib1.dart": """ |
66 import "main.dart" as main; | 66 import "main.dart" as main; |
67 final finalVar = "string1"; | 67 final finalVar = "string1"; |
68 var globalVar = "string2"; | 68 var globalVar = "string2"; |
69 """ | 69 """ |
70 }; | 70 }; |
OLD | NEW |