| 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: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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); | 60 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); |
| 61 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); | 61 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); |
| 62 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); | 62 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); |
| 63 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); | 63 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); |
| 64 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); | 64 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); |
| 65 // InputElement is native, so it should not appear on a classList | 65 // InputElement is native, so it should not appear on a classList |
| 66 Expect.isFalse(outputClassLists[outputUnitForElement(inputElement)] | 66 Expect.isFalse(outputClassLists[outputUnitForElement(inputElement)] |
| 67 .contains(inputElement)); | 67 .contains(inputElement)); |
| 68 | 68 |
| 69 var hunksToLoad = compiler.deferredLoadTask.hunksToLoad; | 69 var hunksToLoad = compiler.deferredLoadTask.hunksToLoad; |
| 70 var hunksLib1 = new Set.from(hunksToLoad["lib1"].map((o) => o.name)); |
| 71 var hunksLib2 = new Set.from(hunksToLoad["lib2"].map((o) => o.name)); |
| 72 var hunksLib4_1 = new Set.from(hunksToLoad["lib4_1"].map((o) => o.name)); |
| 73 var hunksLib4_2 = new Set.from(hunksToLoad["lib4_2"].map((o) => o.name)); |
| 74 Expect.equals(hunksLib1.length, 2); |
| 75 Expect.isTrue(hunksLib1.contains("lib1")); |
| 76 Expect.isTrue(hunksLib1.contains("lib1_lib2") || |
| 77 hunksLib1.contains("lib2_lib1")); |
| 78 Expect.isTrue(hunksLib2.contains("lib2")); |
| 79 Expect.equals(hunksLib2.length, 2); |
| 80 Expect.isTrue(hunksLib2.contains("lib1_lib2") || |
| 81 hunksLib1.contains("lib2_lib1")); |
| 82 Expect.isTrue(hunksLib4_1.contains("lib4_1")); |
| 83 Expect.equals(hunksLib4_1.length, 1); |
| 84 Expect.isTrue(hunksLib4_2.contains("lib4_2")); |
| 85 Expect.equals(hunksLib4_2.length, 1); |
| 86 Expect.equals(hunksToLoad["main"], null); |
| 70 | 87 |
| 71 mapToNames(id) { | |
| 72 return hunksToLoad[id].map((l) { | |
| 73 return new Set.from(l.map((o) => o.name)); | |
| 74 }).toList(); | |
| 75 } | |
| 76 | |
| 77 var hunksLib1 = mapToNames("lib1"); | |
| 78 var hunksLib2 = mapToNames("lib2"); | |
| 79 var hunksLib4_1 = mapToNames("lib4_1"); | |
| 80 var hunksLib4_2 = mapToNames("lib4_2"); | |
| 81 Expect.equals(hunksLib1.length, 2); | |
| 82 Expect.equals(hunksLib1[0].length, 1); | |
| 83 Expect.equals(hunksLib1[1].length, 1); | |
| 84 Expect.isTrue(hunksLib1[0].contains("lib1_lib2") || | |
| 85 hunksLib1[0].contains("lib2_lib1")); | |
| 86 Expect.isTrue(hunksLib1[1].contains("lib1")); | |
| 87 Expect.equals(hunksLib2.length, 2); | |
| 88 Expect.equals(hunksLib2[0].length, 1); | |
| 89 Expect.equals(hunksLib2[1].length, 1); | |
| 90 Expect.isTrue(hunksLib2[0].contains("lib1_lib2") || | |
| 91 hunksLib2[0].contains("lib2_lib1")); | |
| 92 Expect.isTrue(hunksLib2[1].contains("lib2")); | |
| 93 Expect.equals(hunksLib4_1.length, 1); | |
| 94 Expect.equals(hunksLib4_1[0].length, 1); | |
| 95 Expect.isTrue(hunksLib4_1[0].contains("lib4_1")); | |
| 96 Expect.equals(hunksLib4_2.length, 1); | |
| 97 Expect.equals(hunksLib4_2[0].length, 1); | |
| 98 Expect.isTrue(hunksLib4_2[0].contains("lib4_2")); | |
| 99 Expect.equals(hunksToLoad["main"], null); | |
| 100 })); | 88 })); |
| 101 } | 89 } |
| 102 | 90 |
| 103 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and | 91 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and |
| 104 // lib2.foo2. This should trigger seperate output units for main, lib1 and | 92 // lib2.foo2. This should trigger seperate output units for main, lib1 and |
| 105 // lib2. | 93 // lib2. |
| 106 // | 94 // |
| 107 // Both lib1 and lib2 import lib3 directly and | 95 // Both lib1 and lib2 import lib3 directly and |
| 108 // both use lib3.foo3. Therefore a shared output unit for lib1 and lib2 should | 96 // both use lib3.foo3. Therefore a shared output unit for lib1 and lib2 should |
| 109 // be created. | 97 // be created. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 165 |
| 178 bar1() { | 166 bar1() { |
| 179 return "hello"; | 167 return "hello"; |
| 180 } | 168 } |
| 181 | 169 |
| 182 bar2() { | 170 bar2() { |
| 183 return 2; | 171 return 2; |
| 184 } | 172 } |
| 185 """, | 173 """, |
| 186 }; | 174 }; |
| OLD | NEW |