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

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

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:compiler/src/dart2jslib.dart'
15 as dart2js;
16
17 class FakeOutputStream<T> extends EventSink<T> {
18 void add(T event) {}
19 void addError(T event, [StackTrace stackTrace]) {}
20 void close() {}
21 }
22 13
23 void main() { 14 void main() {
24 Uri script = currentDirectory.resolveUri(Platform.script); 15 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES);
25 Uri libraryRoot = script.resolve('../../../sdk/');
26 Uri packageRoot = script.resolve('./packages/');
27
28 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
29 var handler = new FormattingDiagnosticHandler(provider);
30
31 Compiler compiler = new Compiler(provider.readStringFromUri,
32 (name, extension) => new FakeOutputStream(),
33 handler.diagnosticHandler,
34 libraryRoot,
35 packageRoot,
36 [],
37 {});
38 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { 16 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
39 lookupLibrary(name) { 17 lookupLibrary(name) {
40 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 18 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
41 } 19 }
42 20
43 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 21 var main = compiler.mainApp.find(Compiler.MAIN);
44 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 22 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
45 23
46 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 24 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
47 var backend = compiler.backend; 25 var backend = compiler.backend;
48 var classes = backend.emitter.neededClasses; 26 var classes = backend.emitter.neededClasses;
49 var lib1 = lookupLibrary("memory:lib1.dart"); 27 var lib1 = lookupLibrary("memory:lib1.dart");
50 var lib2 = lookupLibrary("memory:lib2.dart"); 28 var lib2 = lookupLibrary("memory:lib2.dart");
51 var foo1 = lib1.find("foo1"); 29 var foo1 = lib1.find("foo1");
52 var foo2 = lib2.find("foo2"); 30 var foo2 = lib2.find("foo2");
53 31
(...skipping 23 matching lines...) Expand all
77 void foo1() { 55 void foo1() {
78 lib1.loadLibrary().then((_) => lib2.foo2()); 56 lib1.loadLibrary().then((_) => lib2.foo2());
79 } 57 }
80 """, 58 """,
81 "lib2.dart":""" 59 "lib2.dart":"""
82 library lib2; 60 library lib2;
83 61
84 void foo2() {} 62 void foo2() {}
85 """, 63 """,
86 }; 64 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/deferred_load_graph_segmentation_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