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 18 matching lines...) Expand all Loading... |
29 var handler = new FormattingDiagnosticHandler(provider); | 29 var handler = new FormattingDiagnosticHandler(provider); |
30 | 30 |
31 Compiler compiler = new Compiler(provider.readStringFromUri, | 31 Compiler compiler = new Compiler(provider.readStringFromUri, |
32 (name, extension) => new FakeOutputStream(), | 32 (name, extension) => new FakeOutputStream(), |
33 handler.diagnosticHandler, | 33 handler.diagnosticHandler, |
34 libraryRoot, | 34 libraryRoot, |
35 packageRoot, | 35 packageRoot, |
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 lookupLibrary(name) { |
| 40 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); |
| 41 } |
| 42 |
39 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); | 43 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); |
40 Expect.isNotNull(main, "Could not find 'main'"); | 44 Expect.isNotNull(main, "Could not find 'main'"); |
41 compiler.deferredLoadTask.onResolutionComplete(main); | 45 compiler.deferredLoadTask.onResolutionComplete(main); |
42 | 46 |
43 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 47 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
44 | 48 |
45 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 49 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
46 var backend = compiler.backend; | 50 var backend = compiler.backend; |
47 var classes = backend.emitter.neededClasses; | 51 var classes = backend.emitter.neededClasses; |
48 var inputElement = classes.where((e) => e.name == 'InputElement').single; | 52 var inputElement = classes.where((e) => e.name == 'InputElement').single; |
49 var lib1 = compiler.libraries["memory:lib1.dart"]; | 53 var lib1 = lookupLibrary("memory:lib1.dart"); |
50 var foo1 = lib1.find("foo1"); | 54 var foo1 = lib1.find("foo1"); |
51 var lib2 = compiler.libraries["memory:lib2.dart"]; | 55 var lib2 = lookupLibrary("memory:lib2.dart"); |
52 var foo2 = lib2.find("foo2"); | 56 var foo2 = lib2.find("foo2"); |
53 var lib3 = compiler.libraries["memory:lib3.dart"]; | 57 var lib3 = lookupLibrary("memory:lib3.dart"); |
54 var foo3 = lib3.find("foo3"); | 58 var foo3 = lib3.find("foo3"); |
55 var lib4 = compiler.libraries["memory:lib4.dart"]; | 59 var lib4 = lookupLibrary("memory:lib4.dart"); |
56 var bar1 = lib4.find("bar1"); | 60 var bar1 = lib4.find("bar1"); |
57 var bar2 = lib4.find("bar2"); | 61 var bar2 = lib4.find("bar2"); |
58 var outputClassLists = backend.emitter.outputClassLists; | 62 var outputClassLists = backend.emitter.outputClassLists; |
59 | 63 |
60 Expect.equals(mainOutputUnit, outputUnitForElement(main)); | 64 Expect.equals(mainOutputUnit, outputUnitForElement(main)); |
61 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); | 65 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo1)); |
62 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); | 66 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo3)); |
63 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); | 67 Expect.notEquals(outputUnitForElement(foo2), outputUnitForElement(foo3)); |
64 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); | 68 Expect.notEquals(outputUnitForElement(foo1), outputUnitForElement(foo2)); |
65 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); | 69 Expect.notEquals(outputUnitForElement(bar1), outputUnitForElement(bar2)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 182 |
179 bar1() { | 183 bar1() { |
180 return "hello"; | 184 return "hello"; |
181 } | 185 } |
182 | 186 |
183 bar2() { | 187 bar2() { |
184 return 2; | 188 return 2; |
185 } | 189 } |
186 """, | 190 """, |
187 }; | 191 }; |
OLD | NEW |