OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.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 | 13 |
14 void main() { | 14 void main() { |
15 asyncTest(() async { | 15 asyncTest(() async { |
16 CompilationResult result = | 16 CompilationResult result = |
17 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); | 17 await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES); |
18 Compiler compiler = result.compiler; | 18 Compiler compiler = result.compiler; |
19 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 19 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
20 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 20 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
21 var lib = | 21 dynamic lib = |
22 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); | 22 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); |
23 var f1 = lib.find("f1"); | 23 var f1 = lib.find("f1"); |
24 var f2 = lib.find("f2"); | 24 var f2 = lib.find("f2"); |
25 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); | 25 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); |
26 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); | 26 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); |
27 }); | 27 }); |
28 } | 28 } |
29 | 29 |
30 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and | 30 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and |
31 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. | 31 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. |
(...skipping 22 matching lines...) Expand all Loading... |
54 "lib.dart": """ | 54 "lib.dart": """ |
55 int f1 () { | 55 int f1 () { |
56 return 1; | 56 return 1; |
57 } | 57 } |
58 | 58 |
59 int f2 () { | 59 int f2 () { |
60 return 2; | 60 return 2; |
61 } | 61 } |
62 """, | 62 """, |
63 }; | 63 }; |
OLD | NEW |