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

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

Issue 2944843002: All strong mode cleaning of dart2js. (Closed)
Patch Set: More issues discovered during testing. Created 3 years, 6 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 = await runCompiler(memorySourceFiles: TEST1); 21 CompilationResult result = await runCompiler(memorySourceFiles: TEST1);
22 Compiler compiler = result.compiler; 22 Compiler compiler = result.compiler;
23 23
24 lookupLibrary(name) { 24 lookupLibrary(name) {
25 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 25 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
26 } 26 }
27 27
28 var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
29 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 28 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
30 29
31 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 30 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
32 var backend = compiler.backend; 31 dynamic lib1 = lookupLibrary("memory:lib1.dart");
33 var lib1 = lookupLibrary("memory:lib1.dart"); 32 dynamic lib2 = lookupLibrary("memory:lib2.dart");
34 var lib2 = lookupLibrary("memory:lib2.dart"); 33 lib1.find("foo1");
35 var foo1 = lib1.find("foo1");
36 var foo2 = lib2.find("foo2"); 34 var foo2 = lib2.find("foo2");
37 35
38 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2)); 36 Expect.notEquals(mainOutputUnit, outputUnitForElement(foo2));
39 }); 37 });
40 } 38 }
41 39
42 void deferredTest2() { 40 void deferredTest2() {
43 asyncTest(() async { 41 asyncTest(() async {
44 CompilationResult result = await runCompiler(memorySourceFiles: TEST2); 42 CompilationResult result = await runCompiler(memorySourceFiles: TEST2);
45 Compiler compiler = result.compiler; 43 Compiler compiler = result.compiler;
46 44
47 lookupLibrary(name) { 45 lookupLibrary(name) {
48 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 46 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
49 } 47 }
50 48
51 var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
52 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 49 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
53 50
54 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; 51 var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
55 var shared = lookupLibrary("memory:shared.dart"); 52 dynamic shared = lookupLibrary("memory:shared.dart");
56 var a = shared.find("A"); 53 var a = shared.find("A");
57 54
58 Expect.equals(mainOutputUnit, outputUnitForElement(a)); 55 Expect.equals(mainOutputUnit, outputUnitForElement(a));
59 }); 56 });
60 } 57 }
61 58
62 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary. 59 // lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary.
63 // Test that this case works. 60 // Test that this case works.
64 const Map TEST1 = const { 61 const Map TEST1 = const {
65 "main.dart": """ 62 "main.dart": """
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 import 'shared.dart'; 106 import 'shared.dart';
110 107
111 toto() { print(new A()); } 108 toto() { print(new A()); }
112 """, 109 """,
113 "shared.dart": """ 110 "shared.dart": """
114 class A {} 111 class A {}
115 class B extends A {} 112 class B extends A {}
116 foo(B b) => null; 113 foo(B b) => null;
117 """, 114 """,
118 }; 115 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/deferred_mirrors_test.dart ('k') | tests/compiler/dart2js/diagnostic_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698