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