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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 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
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'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:compiler/src/compiler.dart'; 10 import 'package:compiler/src/compiler.dart';
11 import 'package:expect/expect.dart'; 11 import 'package:expect/expect.dart';
12 import 'memory_compiler.dart'; 12 import 'memory_compiler.dart';
13 13
14 void main() { 14 void main() {
15 deferredTest1(); 15 deferredTest1();
16 deferredTest2(); 16 deferredTest2();
17 } 17 }
18 18
19 void deferredTest1() { 19 void deferredTest1() {
20 asyncTest(() async { 20 asyncTest(() async {
21 CompilationResult result = 21 CompilationResult result = await runCompiler(memorySourceFiles: TEST1);
22 await runCompiler(memorySourceFiles: TEST1);
23 Compiler compiler = result.compiler; 22 Compiler compiler = result.compiler;
24 23
25 lookupLibrary(name) { 24 lookupLibrary(name) {
26 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 25 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
27 } 26 }
28 27
29 var main = compiler.mainFunction; 28 var main = compiler.mainFunction;
30 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 29 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
31 30
32 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 31 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
(...skipping 23 matching lines...) Expand all
56 var shared = lookupLibrary("memory:shared.dart"); 55 var shared = lookupLibrary("memory:shared.dart");
57 var a = shared.find("A"); 56 var a = shared.find("A");
58 57
59 Expect.equals(mainOutputUnit, outputUnitForElement(a)); 58 Expect.equals(mainOutputUnit, outputUnitForElement(a));
60 }); 59 });
61 } 60 }
62 61
63 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. 62 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary.
64 // Test that this case works. 63 // Test that this case works.
65 const Map TEST1 = const { 64 const Map TEST1 = const {
66 "main.dart":""" 65 "main.dart": """
67 library mainlib; 66 library mainlib;
68 67
69 import 'lib1.dart' as lib1; 68 import 'lib1.dart' as lib1;
70 69
71 void main() { 70 void main() {
72 lib1.foo1(); 71 lib1.foo1();
73 } 72 }
74 """, 73 """,
75 "lib1.dart":""" 74 "lib1.dart": """
76 library lib1; 75 library lib1;
77 76
78 import 'lib2.dart' deferred as lib2; 77 import 'lib2.dart' deferred as lib2;
79 78
80 const def = const DeferredLibrary('lib2'); 79 const def = const DeferredLibrary('lib2');
81 80
82 void foo1() { 81 void foo1() {
83 lib1.loadLibrary().then((_) => lib2.foo2()); 82 lib1.loadLibrary().then((_) => lib2.foo2());
84 } 83 }
85 """, 84 """,
86 "lib2.dart":""" 85 "lib2.dart": """
87 library lib2; 86 library lib2;
88 87
89 void foo2() {} 88 void foo2() {}
90 """, 89 """,
91 }; 90 };
92 91
93 // main indirectly uses class A from shared. A should still be included in the 92 // main indirectly uses class A from shared. A should still be included in the
94 // main fragment. 93 // main fragment.
95 const Map TEST2 = const { 94 const Map TEST2 = const {
96 "main.dart":""" 95 "main.dart": """
97 import 'def.dart' deferred as def; 96 import 'def.dart' deferred as def;
98 import 'shared.dart'; 97 import 'shared.dart';
99 98
100 typedef void F(x); 99 typedef void F(x);
101 100
102 main() { 101 main() {
103 print(foo is F); 102 print(foo is F);
104 def.loadLibrary().then((_) { 103 def.loadLibrary().then((_) {
105 def.toto(); 104 def.toto();
106 }); 105 });
107 } 106 }
108 """, 107 """,
109 "def.dart":""" 108 "def.dart": """
110 import 'shared.dart'; 109 import 'shared.dart';
111 110
112 toto() { print(new A()); } 111 toto() { print(new A()); }
113 """, 112 """,
114 "shared.dart":""" 113 "shared.dart": """
115 class A {} 114 class A {}
116 class B extends A {} 115 class B extends A {}
117 foo(B b) => null; 116 foo(B b) => null;
118 """, 117 """,
119 }; 118 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/deferred_mirrors_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