| 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 25 matching lines...) Expand all Loading... |
| 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 Expect.isNotNull(main, "Could not find 'main'"); | 40 Expect.isNotNull(main, "Could not find 'main'"); |
| 41 compiler.deferredLoadTask.onResolutionComplete(main); | 41 compiler.deferredLoadTask.onResolutionComplete(main); |
| 42 | 42 |
| 43 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 43 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 44 | 44 |
| 45 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 45 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 46 var classes = compiler.backend.emitter.neededClasses; | 46 var backend = compiler.backend; |
| 47 var classes = backend.emitter.neededClasses; |
| 47 var inputElement = classes.where((e) => e.name == 'InputElement').single; | 48 var inputElement = classes.where((e) => e.name == 'InputElement').single; |
| 48 var lib1 = compiler.libraries["memory:lib1.dart"]; | 49 var lib1 = compiler.libraries["memory:lib1.dart"]; |
| 49 var foo1 = lib1.find("foo1"); | 50 var foo1 = lib1.find("foo1"); |
| 50 var lib2 = compiler.libraries["memory:lib2.dart"]; | 51 var lib2 = compiler.libraries["memory:lib2.dart"]; |
| 51 var foo2 = lib2.find("foo2"); | 52 var foo2 = lib2.find("foo2"); |
| 52 var lib3 = compiler.libraries["memory:lib3.dart"]; | 53 var lib3 = compiler.libraries["memory:lib3.dart"]; |
| 53 var foo3 = lib3.find("foo3"); | 54 var foo3 = lib3.find("foo3"); |
| 54 var lib4 = compiler.libraries["memory:lib4.dart"]; | 55 var lib4 = compiler.libraries["memory:lib4.dart"]; |
| 55 var bar1 = lib4.find("bar1"); | 56 var bar1 = lib4.find("bar1"); |
| 56 var bar2 = lib4.find("bar2"); | 57 var bar2 = lib4.find("bar2"); |
| 57 var outputClassLists = compiler.backend.emitter.outputClassLists; | 58 var outputClassLists = backend.emitter.outputClassLists; |
| 58 | 59 |
| 59 Expect.equals(mainOutputUnit, outputUnitForElement(main)); | 60 Expect.equals(mainOutputUnit, outputUnitForElement(main)); |
| 60 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); | 61 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); |
| 61 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); | 62 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); |
| 62 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); | 63 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); |
| 63 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); | 64 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); |
| 64 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); | 65 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); |
| 65 // InputElement is native, so it should not appear on a classList | 66 // InputElement is native, so it should not appear on a classList |
| 66 Expect.isFalse(outputClassLists[outputUnitForElement(inputElement)] | 67 Expect.isFalse(outputClassLists[outputUnitForElement(inputElement)] |
| 67 .contains(inputElement)); | 68 .contains(inputElement)); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 178 |
| 178 bar1() { | 179 bar1() { |
| 179 return "hello"; | 180 return "hello"; |
| 180 } | 181 } |
| 181 | 182 |
| 182 bar2() { | 183 bar2() { |
| 183 return 2; | 184 return 2; |
| 184 } | 185 } |
| 185 """, | 186 """, |
| 186 }; | 187 }; |
| OLD | NEW |