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 of the graph segmentation algorithm used by deferred loading | 5 // Test of the graph segmentation algorithm used by deferred loading |
6 // to determine which elements can be deferred and which libraries | 6 // to determine which elements can be deferred and which libraries |
7 // much be included in the initial download (loaded eagerly). | 7 // much be included in the initial download (loaded eagerly). |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
(...skipping 22 matching lines...) Expand all Loading... |
33 handler.diagnosticHandler, | 33 handler.diagnosticHandler, |
34 libraryRoot, | 34 libraryRoot, |
35 packageRoot, | 35 packageRoot, |
36 [], | 36 [], |
37 {}); | 37 {}); |
38 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 38 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
39 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); | 39 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); |
40 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 40 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
41 | 41 |
42 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 42 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
43 var classes = compiler.backend.emitter.neededClasses; | 43 var backend = compiler.backend; |
| 44 var classes = backend.emitter.neededClasses; |
44 var lib1 = compiler.libraries["memory:lib1.dart"]; | 45 var lib1 = compiler.libraries["memory:lib1.dart"]; |
45 var lib2 = compiler.libraries["memory:lib2.dart"]; | 46 var lib2 = compiler.libraries["memory:lib2.dart"]; |
46 var foo1 = lib1.find("foo1"); | 47 var foo1 = lib1.find("foo1"); |
47 var foo2 = lib2.find("foo2"); | 48 var foo2 = lib2.find("foo2"); |
48 | 49 |
49 var outputClassLists = compiler.backend.emitter.outputClassLists; | 50 var outputClassLists = backend.emitter.outputClassLists; |
50 | 51 |
51 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2)); | 52 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2)); |
52 })); | 53 })); |
53 } | 54 } |
54 | 55 |
55 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. | 56 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. |
56 // Test that this case works. | 57 // Test that this case works. |
57 const Map MEMORY_SOURCE_FILES = const { | 58 const Map MEMORY_SOURCE_FILES = const { |
58 "main.dart":""" | 59 "main.dart":""" |
59 library mainlib; | 60 library mainlib; |
(...skipping 15 matching lines...) Expand all Loading... |
75 void foo1() { | 76 void foo1() { |
76 def.load().then((_) => lib2.foo2()); | 77 def.load().then((_) => lib2.foo2()); |
77 } | 78 } |
78 """, | 79 """, |
79 "lib2.dart":""" | 80 "lib2.dart":""" |
80 library lib2; | 81 library lib2; |
81 | 82 |
82 void foo2() {} | 83 void foo2() {} |
83 """, | 84 """, |
84 }; | 85 }; |
OLD | NEW |