| 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 20 matching lines...) Expand all Loading... |
| 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 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 39 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 40 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 40 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 41 var lib = | 41 var lib = compiler.libraries["memory:lib.dart"]; |
| 42 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); | |
| 43 var f1 = lib.find("f1"); | 42 var f1 = lib.find("f1"); |
| 44 var f2 = lib.find("f2"); | 43 var f2 = lib.find("f2"); |
| 45 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); | 44 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); |
| 46 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); | 45 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); |
| 47 })); | 46 })); |
| 48 } | 47 } |
| 49 | 48 |
| 50 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and | 49 // The main library imports lib1 and lib2 deferred and use lib1.foo1 and |
| 51 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. | 50 // lib2.foo2. This should trigger seperate outputunits for main, lib1 and lib2. |
| 52 // | 51 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 73 } | 72 } |
| 74 """, "lib.dart": """ | 73 """, "lib.dart": """ |
| 75 int f1 () { | 74 int f1 () { |
| 76 return 1; | 75 return 1; |
| 77 } | 76 } |
| 78 | 77 |
| 79 int f2 () { | 78 int f2 () { |
| 80 return 2; | 79 return 2; |
| 81 } | 80 } |
| 82 """,}; | 81 """,}; |
| OLD | NEW |