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