| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 44 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 45 | 45 |
| 46 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 46 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 47 var backend = compiler.backend; | 47 var backend = compiler.backend; |
| 48 var classes = backend.emitter.neededClasses; | 48 var classes = backend.emitter.neededClasses; |
| 49 var lib1 = lookupLibrary("memory:lib1.dart"); | 49 var lib1 = lookupLibrary("memory:lib1.dart"); |
| 50 var lib2 = lookupLibrary("memory:lib2.dart"); | 50 var lib2 = lookupLibrary("memory:lib2.dart"); |
| 51 var foo1 = lib1.find("foo1"); | 51 var foo1 = lib1.find("foo1"); |
| 52 var foo2 = lib2.find("foo2"); | 52 var foo2 = lib2.find("foo2"); |
| 53 | 53 |
| 54 var outputClassLists = backend.emitter.outputClassLists; | |
| 55 | |
| 56 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2)); | 54 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2)); |
| 57 })); | 55 })); |
| 58 } | 56 } |
| 59 | 57 |
| 60 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. | 58 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. |
| 61 // Test that this case works. | 59 // Test that this case works. |
| 62 const Map MEMORY_SOURCE_FILES = const { | 60 const Map MEMORY_SOURCE_FILES = const { |
| 63 "main.dart":""" | 61 "main.dart":""" |
| 64 library mainlib; | 62 library mainlib; |
| 65 | 63 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 void foo1() { | 77 void foo1() { |
| 80 lib1.loadLibrary().then((_) => lib2.foo2()); | 78 lib1.loadLibrary().then((_) => lib2.foo2()); |
| 81 } | 79 } |
| 82 """, | 80 """, |
| 83 "lib2.dart":""" | 81 "lib2.dart":""" |
| 84 library lib2; | 82 library lib2; |
| 85 | 83 |
| 86 void foo2() {} | 84 void foo2() {} |
| 87 """, | 85 """, |
| 88 }; | 86 }; |
| OLD | NEW |