| 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 ['--analyze-only']); | 29 ['--analyze-only']); |
| 30 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 30 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 31 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); | 31 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); |
| 32 Expect.isNotNull(main, "Could not find 'main'"); | 32 Expect.isNotNull(main, "Could not find 'main'"); |
| 33 compiler.deferredLoadTask.onResolutionComplete(main); | 33 compiler.deferredLoadTask.onResolutionComplete(main); |
| 34 | 34 |
| 35 var deferredClasses = | 35 var deferredClasses = |
| 36 compiler.deferredLoadTask.allDeferredElements.where((e) => e.isClass()) | 36 compiler.deferredLoadTask.allDeferredElements.where((e) => e.isClass()) |
| 37 .toSet(); | 37 .toSet(); |
| 38 | 38 |
| 39 var dateTime = | 39 var dateTime = deferredClasses.where((e) => e.name == 'DateTime').single; |
| 40 deferredClasses | |
| 41 .where((e) => e.name == 'DateTime').single; | |
| 42 | 40 |
| 43 var myClass = | 41 var myClass = deferredClasses.where((e) => e.name == 'MyClass').single; |
| 44 deferredClasses.where((e) => e.name == 'MyClass').single; | |
| 45 | 42 |
| 46 var deferredLibrary = compiler.libraries['memory:deferred.dart']; | 43 var deferredLibrary = compiler.libraries['memory:deferred.dart']; |
| 47 | 44 |
| 48 Expect.equals(deferredLibrary, myClass.getLibrary()); | 45 Expect.equals(deferredLibrary, myClass.getLibrary()); |
| 49 Expect.equals(compiler.coreLibrary, dateTime.declaration.getLibrary()); | 46 Expect.equals(compiler.coreLibrary, dateTime.declaration.getLibrary()); |
| 50 })); | 47 })); |
| 51 } | 48 } |
| 52 | 49 |
| 53 const Map MEMORY_SOURCE_FILES = const { | 50 const Map MEMORY_SOURCE_FILES = const { |
| 54 'main.dart': """ | 51 'main.dart': """ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 class MyClass { | 68 class MyClass { |
| 72 const MyClass(); | 69 const MyClass(); |
| 73 | 70 |
| 74 foo(x) { | 71 foo(x) { |
| 75 new DateTime.now(); | 72 new DateTime.now(); |
| 76 return (x - 3) ~/ 2; | 73 return (x - 3) ~/ 2; |
| 77 } | 74 } |
| 78 } | 75 } |
| 79 """, | 76 """, |
| 80 }; | 77 }; |
| OLD | NEW |