| 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:async_helper/async_helper.dart'; |
| 10 import 'package:compiler/src/dart2jslib.dart'; |
| 9 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; | 12 import 'memory_compiler.dart'; |
| 11 import 'memory_source_file_helper.dart'; | |
| 12 import "dart:async"; | |
| 13 | |
| 14 class FakeOutputStream<T> extends EventSink<T> { | |
| 15 void add(T event) {} | |
| 16 void addError(T event, [StackTrace stackTrace]) {} | |
| 17 void close() {} | |
| 18 } | |
| 19 | 13 |
| 20 void main() { | 14 void main() { |
| 21 Uri script = currentDirectory.resolveUri(Platform.script); | 15 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES); |
| 22 Uri libraryRoot = script.resolve('../../../sdk/'); | |
| 23 Uri packageRoot = script.resolve('./packages/'); | |
| 24 | |
| 25 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); | |
| 26 var handler = new FormattingDiagnosticHandler(provider); | |
| 27 | |
| 28 Compiler compiler = new Compiler(provider.readStringFromUri, | |
| 29 (name, extension) => new FakeOutputStream(), | |
| 30 handler.diagnosticHandler, | |
| 31 libraryRoot, | |
| 32 packageRoot, | |
| 33 [], | |
| 34 {}); | |
| 35 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 16 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; | 17 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; |
| 37 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 18 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 38 var lib = | 19 var lib = |
| 39 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); | 20 compiler.libraryLoader.lookupLibrary(Uri.parse("memory:lib.dart")); |
| 40 var f1 = lib.find("f1"); | 21 var f1 = lib.find("f1"); |
| 41 var f2 = lib.find("f2"); | 22 var f2 = lib.find("f2"); |
| 42 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); | 23 Expect.notEquals(mainOutputUnit, outputUnitForElement(f1)); |
| 43 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); | 24 Expect.equals(mainOutputUnit, outputUnitForElement(f2)); |
| 44 })); | 25 })); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 68 } | 49 } |
| 69 """, "lib.dart": """ | 50 """, "lib.dart": """ |
| 70 int f1 () { | 51 int f1 () { |
| 71 return 1; | 52 return 1; |
| 72 } | 53 } |
| 73 | 54 |
| 74 int f2 () { | 55 int f2 () { |
| 75 return 2; | 56 return 2; |
| 76 } | 57 } |
| 77 """,}; | 58 """,}; |
| OLD | NEW |