| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Both lib1 and lib2 import lib3 directly and | 52 // Both lib1 and lib2 import lib3 directly and |
| 53 // both use lib3.foo3. Therefore a shared output unit for lib1 and lib2 should | 53 // both use lib3.foo3. Therefore a shared output unit for lib1 and lib2 should |
| 54 // be created. | 54 // be created. |
| 55 // | 55 // |
| 56 // lib1 and lib2 also import lib4 deferred, but lib1 uses lib4.bar1 and lib2 | 56 // lib1 and lib2 also import lib4 deferred, but lib1 uses lib4.bar1 and lib2 |
| 57 // uses lib4.bar2. So two output units should be created for lib4, one for each | 57 // uses lib4.bar2. So two output units should be created for lib4, one for each |
| 58 // import. | 58 // import. |
| 59 const Map MEMORY_SOURCE_FILES = const {"main.dart": """ | 59 const Map MEMORY_SOURCE_FILES = const {"main.dart": """ |
| 60 import "dart:async"; | 60 import "dart:async"; |
| 61 | 61 |
| 62 @def import 'lib.dart' show f1; | 62 @def import 'lib.dart' as lib show f1; |
| 63 import 'lib.dart' show f2; | 63 import 'lib.dart' show f2; |
| 64 | 64 |
| 65 const def = const DeferredLibrary("deferred"); | 65 const def = const DeferredLibrary("deferred"); |
| 66 | 66 |
| 67 void main() { | 67 void main() { |
| 68 print(f2()); | 68 print(f2()); |
| 69 def.load().then((_) { | 69 def.load().then((_) { |
| 70 print(f1()); | 70 print(lib.f1()); |
| 71 }); | 71 }); |
| 72 } | 72 } |
| 73 """, "lib.dart": """ | 73 """, "lib.dart": """ |
| 74 int f1 () { | 74 int f1 () { |
| 75 return 1; | 75 return 1; |
| 76 } | 76 } |
| 77 | 77 |
| 78 int f2 () { | 78 int f2 () { |
| 79 return 2; | 79 return 2; |
| 80 } | 80 } |
| 81 """,}; | 81 """,}; |
| OLD | NEW |