| 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"; |
| 11 import 'memory_source_file_helper.dart'; | 11 import 'memory_source_file_helper.dart'; |
| 12 | 12 |
| 13 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 13 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 14 as dart2js; | 14 as dart2js; |
| 15 | 15 |
| 16 void main() { | 16 void main() { |
| 17 Uri script = currentDirectory.resolveUri(Platform.script); | 17 Uri script = currentDirectory.resolveUri(Platform.script); |
| 18 Uri libraryRoot = script.resolve('../../../sdk/'); | 18 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 19 Uri packageRoot = script.resolve('./packages/'); | 19 Uri packageRoot = script.resolve('./packages/'); |
| 20 | 20 |
| 21 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); | 21 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); |
| 22 var handler = new FormattingDiagnosticHandler(provider); | 22 var handler = new FormattingDiagnosticHandler(provider); |
| 23 | 23 |
| 24 Compiler compiler = new Compiler(provider.readStringFromUri, | 24 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 25 (name, extension) => null, | 25 (name, extension) => null, |
| 26 handler.diagnosticHandler, | 26 handler.diagnosticHandler, |
| 27 libraryRoot, | 27 libraryRoot, |
| 28 packageRoot, | 28 packageRoot, |
| 29 ['--analyze-only']); | 29 ['--analyze-only'], |
| 30 {}); |
| 30 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 31 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 31 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); | 32 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); |
| 32 Expect.isNotNull(main, "Could not find 'main'"); | 33 Expect.isNotNull(main, "Could not find 'main'"); |
| 33 compiler.deferredLoadTask.onResolutionComplete(main); | 34 compiler.deferredLoadTask.onResolutionComplete(main); |
| 34 | 35 |
| 35 var deferredClasses = | 36 var deferredClasses = |
| 36 compiler.deferredLoadTask.allDeferredElements.where((e) => e.isClass()) | 37 compiler.deferredLoadTask.allDeferredElements.where((e) => e.isClass()) |
| 37 .toSet(); | 38 .toSet(); |
| 38 | 39 |
| 39 var dateTime = deferredClasses.where((e) => e.name == 'DateTime').single; | 40 var dateTime = deferredClasses.where((e) => e.name == 'DateTime').single; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 class MyClass { | 69 class MyClass { |
| 69 const MyClass(); | 70 const MyClass(); |
| 70 | 71 |
| 71 foo(x) { | 72 foo(x) { |
| 72 new DateTime.now(); | 73 new DateTime.now(); |
| 73 return (x - 3) ~/ 2; | 74 return (x - 3) ~/ 2; |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 """, | 77 """, |
| 77 }; | 78 }; |
| OLD | NEW |