Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 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 = |
| 40 deferredClasses | 40 deferredClasses |
|
kasperl
2013/10/18 06:44:57
Does the where invocation fit on the same line as
lukas
2013/10/18 08:39:46
Done.
| |
| 41 .where((e) => e.name.slowToString() == 'DateTime').single; | 41 .where((e) => e.name == 'DateTime').single; |
| 42 | 42 |
| 43 var myClass = | 43 var myClass = |
| 44 deferredClasses.where((e) => e.name.slowToString() == 'MyClass').single; | 44 deferredClasses.where((e) => e.name == 'MyClass').single; |
| 45 | 45 |
| 46 var deferredLibrary = compiler.libraries['memory:deferred.dart']; | 46 var deferredLibrary = compiler.libraries['memory:deferred.dart']; |
| 47 | 47 |
| 48 Expect.equals(deferredLibrary, myClass.getLibrary()); | 48 Expect.equals(deferredLibrary, myClass.getLibrary()); |
| 49 Expect.equals(compiler.coreLibrary, dateTime.declaration.getLibrary()); | 49 Expect.equals(compiler.coreLibrary, dateTime.declaration.getLibrary()); |
| 50 })); | 50 })); |
| 51 } | 51 } |
| 52 | 52 |
| 53 const Map MEMORY_SOURCE_FILES = const { | 53 const Map MEMORY_SOURCE_FILES = const { |
| 54 'main.dart': """ | 54 'main.dart': """ |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 71 class MyClass { | 71 class MyClass { |
| 72 const MyClass(); | 72 const MyClass(); |
| 73 | 73 |
| 74 foo(x) { | 74 foo(x) { |
| 75 new DateTime.now(); | 75 new DateTime.now(); |
| 76 return (x - 3) ~/ 2; | 76 return (x - 3) ~/ 2; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 """, | 79 """, |
| 80 }; | 80 }; |
| OLD | NEW |