| 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/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
| 10 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 11 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
| 12 import 'output_collector.dart'; | 13 import 'output_collector.dart'; |
| 13 | 14 |
| 14 void main() { | 15 void main() { |
| 15 OutputCollector collector = new OutputCollector(); | 16 OutputCollector collector = new OutputCollector(); |
| 16 asyncTest(() async { | 17 asyncTest(() async { |
| 17 CompilationResult result = await runCompiler( | 18 CompilationResult result = await runCompiler( |
| 18 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector); | 19 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector); |
| 19 Compiler compiler = result.compiler; | 20 Compiler compiler = result.compiler; |
| 20 lookupLibrary(name) { | 21 lookupLibrary(name) { |
| 21 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); | 22 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); |
| 22 } | 23 } |
| 23 | 24 |
| 24 var main = compiler.mainFunction; | 25 var main = compiler.mainFunction; |
| 25 Expect.isNotNull(main, "Could not find 'main'"); | 26 Expect.isNotNull(main, "Could not find 'main'"); |
| 26 compiler.deferredLoadTask.onResolutionComplete(main); | 27 compiler.deferredLoadTask.onResolutionComplete(main); |
| 27 | 28 |
| 28 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 29 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 29 | 30 |
| 30 var lib1 = lookupLibrary("memory:lib1.dart"); | 31 var lib1 = lookupLibrary("memory:lib1.dart"); |
| 31 var foo1 = lib1.find("finalVar"); | 32 var foo1 = lib1.find("finalVar"); |
| 32 var ou_lib1 = outputUnitForElement(foo1); | 33 var ou_lib1 = outputUnitForElement(foo1); |
| 33 | 34 |
| 34 String mainOutput = collector.getOutput("", "js"); | 35 String mainOutput = collector.getOutput("", OutputType.js); |
| 35 String lib1Output = collector.getOutput("out_${ou_lib1.name}", "part.js"); | 36 String lib1Output = |
| 37 collector.getOutput("out_${ou_lib1.name}", OutputType.jsPart); |
| 36 // Test that the deferred globals are not inlined into the main file. | 38 // Test that the deferred globals are not inlined into the main file. |
| 37 RegExp re1 = new RegExp(r"= .string1"); | 39 RegExp re1 = new RegExp(r"= .string1"); |
| 38 RegExp re2 = new RegExp(r"= .string2"); | 40 RegExp re2 = new RegExp(r"= .string2"); |
| 39 Expect.isTrue(re1.hasMatch(lib1Output)); | 41 Expect.isTrue(re1.hasMatch(lib1Output)); |
| 40 Expect.isTrue(re2.hasMatch(lib1Output)); | 42 Expect.isTrue(re2.hasMatch(lib1Output)); |
| 41 Expect.isFalse(re1.hasMatch(mainOutput)); | 43 Expect.isFalse(re1.hasMatch(mainOutput)); |
| 42 Expect.isFalse(re2.hasMatch(mainOutput)); | 44 Expect.isFalse(re2.hasMatch(mainOutput)); |
| 43 }); | 45 }); |
| 44 } | 46 } |
| 45 | 47 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 print(lib1.globalVar); | 60 print(lib1.globalVar); |
| 59 }); | 61 }); |
| 60 } | 62 } |
| 61 """, | 63 """, |
| 62 "lib1.dart": """ | 64 "lib1.dart": """ |
| 63 import "main.dart" as main; | 65 import "main.dart" as main; |
| 64 final finalVar = "string1"; | 66 final finalVar = "string1"; |
| 65 var globalVar = "string2"; | 67 var globalVar = "string2"; |
| 66 """ | 68 """ |
| 67 }; | 69 }; |
| OLD | NEW |