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 we do not accidentally leak code from deferred libraries but do | 5 // Test that we do not accidentally leak code from deferred libraries but do |
6 // allow inlining of empty functions and from main. | 6 // allow inlining of empty functions and from main. |
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'; |
(...skipping 14 matching lines...) Expand all Loading... |
25 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 25 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
26 | 26 |
27 var lib1 = lookupLibrary("memory:lib1.dart"); | 27 var lib1 = lookupLibrary("memory:lib1.dart"); |
28 var inlineMeAway = lib1.find("inlineMeAway"); | 28 var inlineMeAway = lib1.find("inlineMeAway"); |
29 var ou_lib1 = outputUnitForElement(inlineMeAway); | 29 var ou_lib1 = outputUnitForElement(inlineMeAway); |
30 | 30 |
31 var lib3 = lookupLibrary("memory:lib3.dart"); | 31 var lib3 = lookupLibrary("memory:lib3.dart"); |
32 var sameContextInline = lib3.find("sameContextInline"); | 32 var sameContextInline = lib3.find("sameContextInline"); |
33 var ou_lib3 = outputUnitForElement(sameContextInline); | 33 var ou_lib3 = outputUnitForElement(sameContextInline); |
34 | 34 |
35 // Test that we actually got differnt output units. | 35 // Test that we actually got different output units. |
36 Expect.notEquals(ou_lib1.name, ou_lib3.name); | 36 Expect.notEquals(ou_lib1.name, ou_lib3.name); |
37 | 37 |
38 String mainOutput = collector.getOutput("", OutputType.js); | 38 String mainOutput = collector.getOutput("", OutputType.js); |
39 String lib1Output = | 39 String lib1Output = |
40 collector.getOutput("out_${ou_lib1.name}", OutputType.jsPart); | 40 collector.getOutput("out_${ou_lib1.name}", OutputType.jsPart); |
41 String lib3Output = | 41 String lib3Output = |
42 collector.getOutput("out_${ou_lib3.name}", OutputType.jsPart); | 42 collector.getOutput("out_${ou_lib3.name}", OutputType.jsPart); |
43 | 43 |
44 RegExp re1 = new RegExp(r"inlined as empty"); | 44 RegExp re1 = new RegExp(r"inlined as empty"); |
45 RegExp re2 = new RegExp(r"inlined from main"); | 45 RegExp re2 = new RegExp(r"inlined from main"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 import "lib3.dart" as lib3; | 102 import "lib3.dart" as lib3; |
103 | 103 |
104 test() { | 104 test() { |
105 print(lib3.sameContextInline("should be inlined")); | 105 print(lib3.sameContextInline("should be inlined")); |
106 } | 106 } |
107 """, | 107 """, |
108 "lib3.dart": """ | 108 "lib3.dart": """ |
109 sameContextInline(x) => "inline same context" + x; | 109 sameContextInline(x) => "inline same context" + x; |
110 """ | 110 """ |
111 }; | 111 }; |
OLD | NEW |