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

Side by Side Diff: tests/compiler/dart2js/deferred_dont_inline_deferred_constants_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 that the additional runtime type support is output to the right 5 // Test that the additional runtime type support is output to the right
6 // Files when using deferred loading. 6 // Files when using deferred loading.
7 7
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:compiler/src/compiler.dart'; 9 import 'package:compiler/src/compiler.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
11 import 'memory_compiler.dart'; 11 import 'memory_compiler.dart';
12 import 'output_collector.dart'; 12 import 'output_collector.dart';
13 13
14 void main() { 14 void main() {
15 asyncTest(() async { 15 asyncTest(() async {
16 OutputCollector collector = new OutputCollector(); 16 OutputCollector collector = new OutputCollector();
17 CompilationResult result = await runCompiler( 17 CompilationResult result = await runCompiler(
18 memorySourceFiles: MEMORY_SOURCE_FILES, 18 memorySourceFiles: MEMORY_SOURCE_FILES, outputProvider: collector);
19 outputProvider: collector);
20 Compiler compiler = result.compiler; 19 Compiler compiler = result.compiler;
21 20
22 lookupLibrary(name) { 21 lookupLibrary(name) {
23 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 22 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
24 } 23 }
25 24
26 var main = compiler.mainFunction; 25 var main = compiler.mainFunction;
27 Expect.isNotNull(main, "Could not find 'main'"); 26 Expect.isNotNull(main, "Could not find 'main'");
28 compiler.deferredLoadTask.onResolutionComplete(main); 27 compiler.deferredLoadTask.onResolutionComplete(main);
29 28
30 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 29 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
31 30
32 var lib1 = lookupLibrary("memory:lib1.dart"); 31 var lib1 = lookupLibrary("memory:lib1.dart");
33 var foo1 = lib1.find("foo"); 32 var foo1 = lib1.find("foo");
34 var ou_lib1 = outputUnitForElement(foo1); 33 var ou_lib1 = outputUnitForElement(foo1);
35 34
36 var lib2 = lookupLibrary("memory:lib2.dart"); 35 var lib2 = lookupLibrary("memory:lib2.dart");
37 var foo2 = lib2.find("foo"); 36 var foo2 = lib2.find("foo");
38 var ou_lib2 = outputUnitForElement(foo2); 37 var ou_lib2 = outputUnitForElement(foo2);
39 38
40 var fooMain = compiler.mainApp.find("foo"); 39 var fooMain = compiler.mainApp.find("foo");
41 var ou_lib1_lib2 = outputUnitForElement(fooMain); 40 var ou_lib1_lib2 = outputUnitForElement(fooMain);
42 41
43 String mainOutput = collector.getOutput("","js"); 42 String mainOutput = collector.getOutput("", "js");
44 String lib1Output = collector.getOutput("out_${ou_lib1.name}", "part.js"); 43 String lib1Output = collector.getOutput("out_${ou_lib1.name}", "part.js");
45 String lib2Output = collector.getOutput("out_${ou_lib2.name}", "part.js"); 44 String lib2Output = collector.getOutput("out_${ou_lib2.name}", "part.js");
46 String lib12Output = 45 String lib12Output =
47 collector.getOutput("out_${ou_lib1_lib2.name}", "part.js"); 46 collector.getOutput("out_${ou_lib1_lib2.name}", "part.js");
48 // Test that the deferred constants are not inlined into the main file. 47 // Test that the deferred constants are not inlined into the main file.
49 RegExp re1 = new RegExp(r"= .string1"); 48 RegExp re1 = new RegExp(r"= .string1");
50 RegExp re2 = new RegExp(r"= .string2"); 49 RegExp re2 = new RegExp(r"= .string2");
51 RegExp re3 = new RegExp(r"= 1010"); 50 RegExp re3 = new RegExp(r"= 1010");
52 Expect.isTrue(re1.hasMatch(lib1Output)); 51 Expect.isTrue(re1.hasMatch(lib1Output));
53 Expect.isTrue(re2.hasMatch(lib1Output)); 52 Expect.isTrue(re2.hasMatch(lib1Output));
(...skipping 23 matching lines...) Expand all
77 Expect.isTrue(new RegExp(r"C.C_2 =").hasMatch(lib12Output)); 76 Expect.isTrue(new RegExp(r"C.C_2 =").hasMatch(lib12Output));
78 77
79 // "string4" is shared between lib1 and lib2, but it can be inlined. 78 // "string4" is shared between lib1 and lib2, but it can be inlined.
80 Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib1Output)); 79 Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib1Output));
81 Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib2Output)); 80 Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib2Output));
82 Expect.isFalse(new RegExp(r"= .string4").hasMatch(lib12Output)); 81 Expect.isFalse(new RegExp(r"= .string4").hasMatch(lib12Output));
83 }); 82 });
84 } 83 }
85 84
86 // Make sure that deferred constants are not inlined into the main hunk. 85 // Make sure that deferred constants are not inlined into the main hunk.
87 const Map MEMORY_SOURCE_FILES = const {"main.dart": """ 86 const Map MEMORY_SOURCE_FILES = const {
87 "main.dart": """
88 import "dart:async"; 88 import "dart:async";
89 89
90 import 'lib1.dart' deferred as lib1; 90 import 'lib1.dart' deferred as lib1;
91 import 'lib2.dart' deferred as lib2; 91 import 'lib2.dart' deferred as lib2;
92 92
93 const c = "string3"; 93 const c = "string3";
94 94
95 class C { 95 class C {
96 final p; 96 final p;
97 const C(this.p); 97 const C(this.p);
(...skipping 14 matching lines...) Expand all
112 print(lib2.C4); 112 print(lib2.C4);
113 print(lib1.C5); 113 print(lib1.C5);
114 print(lib2.C5); 114 print(lib2.C5);
115 print(lib1.C6); 115 print(lib1.C6);
116 print(lib2.C6); 116 print(lib2.C6);
117 print("string4"); 117 print("string4");
118 print(const C(1)); 118 print(const C(1));
119 }); 119 });
120 }); 120 });
121 } 121 }
122 """, "lib1.dart": """ 122 """,
123 "lib1.dart": """
123 import "main.dart" as main; 124 import "main.dart" as main;
124 const C1 = "string1"; 125 const C1 = "string1";
125 const C2 = 1010; 126 const C2 = 1010;
126 class C { 127 class C {
127 static const C3 = "string2"; 128 static const C3 = "string2";
128 } 129 }
129 const C4 = "string4"; 130 const C4 = "string4";
130 const C5 = const main.C(1); 131 const C5 = const main.C(1);
131 const C6 = const main.C(2); 132 const C6 = const main.C(2);
132 foo() { 133 foo() {
133 print("lib1"); 134 print("lib1");
134 main.foo(); 135 main.foo();
135 } 136 }
136 """, "lib2.dart": """ 137 """,
138 "lib2.dart": """
137 import "main.dart" as main; 139 import "main.dart" as main;
138 const C4 = "string4"; 140 const C4 = "string4";
139 const C5 = const main.C(1); 141 const C5 = const main.C(1);
140 const C6 = const main.C(2); 142 const C6 = const main.C(2);
141 foo() { 143 foo() {
142 print("lib2"); 144 print("lib2");
143 main.foo(); 145 main.foo();
144 } 146 }
145 """}; 147 """
148 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698