Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'memory_source_file_helper.dart'; 11 import 'memory_source_file_helper.dart';
11 12
12 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 13 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
13 as dart2js; 14 as dart2js;
14 15
15 void main() { 16 void main() {
16 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); 17 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
17 Uri libraryRoot = script.resolve('../../../sdk/'); 18 Uri libraryRoot = script.resolve('../../../sdk/');
18 Uri packageRoot = script.resolve('./packages/'); 19 Uri packageRoot = script.resolve('./packages/');
19 20
20 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES; 21 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
21 var provider = new MemorySourceFileProvider();
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 compiler.run(Uri.parse('memory:main.dart')); 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
41 .where((e) => e.name.slowToString() == 'DateTime').single; 41 .where((e) => e.name.slowToString() == '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.slowToString() == '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 const Map MEMORY_SOURCE_FILES = const { 53 const Map MEMORY_SOURCE_FILES = const {
53 'main.dart': """ 54 'main.dart': """
54 import 'dart:async'; 55 import 'dart:async';
55 56
56 @lazy import 'deferred.dart'; 57 @lazy import 'deferred.dart';
57 58
58 const lazy = const DeferredLibrary('deferred'); 59 const lazy = const DeferredLibrary('deferred');
59 60
(...skipping 10 matching lines...) Expand all
70 class MyClass { 71 class MyClass {
71 const MyClass(); 72 const MyClass();
72 73
73 foo(x) { 74 foo(x) {
74 new DateTime.now(); 75 new DateTime.now();
75 return (x - 3) ~/ 2; 76 return (x - 3) ~/ 2;
76 } 77 }
77 } 78 }
78 """, 79 """,
79 }; 80 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/dead_code_test.dart ('k') | tests/compiler/dart2js/diagnose_ambiguous_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698