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

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

Issue 2875313002: Access BackendUsage through ClosedWorld (Closed)
Patch Set: Created 3 years, 7 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 'dart:async'; 9 import 'dart:async';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 void main() { 26 void main() {
27 asyncTest(runTests); 27 asyncTest(runTests);
28 } 28 }
29 29
30 runTests() async { 30 runTests() async {
31 await runTest('memory:main.dart', (compiler) { 31 await runTest('memory:main.dart', (compiler) {
32 var main = compiler.mainFunction; 32 var main = compiler.mainFunction;
33 Expect.isNotNull(main, "Could not find 'main'"); 33 Expect.isNotNull(main, "Could not find 'main'");
34 compiler.deferredLoadTask.onResolutionComplete(main); 34 compiler.deferredLoadTask.onResolutionComplete(
35 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
35 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
36 37
37 var lib1 = lookupLibrary(compiler, "memory:lib1.dart"); 38 var lib1 = lookupLibrary(compiler, "memory:lib1.dart");
38 var lib2 = lookupLibrary(compiler, "memory:lib2.dart"); 39 var lib2 = lookupLibrary(compiler, "memory:lib2.dart");
39 var mathLib = lookupLibrary(compiler, "dart:math"); 40 var mathLib = lookupLibrary(compiler, "dart:math");
40 var sin = mathLib.find('sin'); 41 var sin = mathLib.find('sin');
41 var foo1 = lib1.find("foo1"); 42 var foo1 = lib1.find("foo1");
42 var foo2 = lib2.find("foo2"); 43 var foo2 = lib2.find("foo2");
43 var field2 = lib2.find("field2"); 44 var field2 = lib2.find("field2");
44 45
45 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1)); 46 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1));
46 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin)); 47 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin));
47 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2)); 48 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2));
48 }); 49 });
49 await runTest('memory:main2.dart', (compiler) { 50 await runTest('memory:main2.dart', (compiler) {
50 // Just check that the compile runs. 51 // Just check that the compile runs.
51 // This is a regression test. 52 // This is a regression test.
52 Expect.isTrue(true); 53 Expect.isTrue(true);
53 }); 54 });
54 await runTest('memory:main3.dart', (compiler) { 55 await runTest('memory:main3.dart', (compiler) {
55 var main = compiler.mainFunction; 56 var main = compiler.mainFunction;
56 Expect.isNotNull(main, "Could not find 'main'"); 57 Expect.isNotNull(main, "Could not find 'main'");
57 compiler.deferredLoadTask.onResolutionComplete(main); 58 compiler.deferredLoadTask.onResolutionComplete(
59 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
58 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 60 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
59 61
60 Expect.isFalse(compiler.backend.mirrorsData.hasInsufficientMirrorsUsed); 62 Expect.isFalse(compiler.backend.mirrorsData.hasInsufficientMirrorsUsed);
61 var mainLib = lookupLibrary(compiler, "memory:main3.dart"); 63 var mainLib = lookupLibrary(compiler, "memory:main3.dart");
62 var lib3 = lookupLibrary(compiler, "memory:lib3.dart"); 64 var lib3 = lookupLibrary(compiler, "memory:lib3.dart");
63 var C = mainLib.find("C"); 65 var C = mainLib.find("C");
64 var foo = lib3.find("foo"); 66 var foo = lib3.find("foo");
65 67
66 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo)); 68 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo));
67 Expect.equals(outputUnitForElement(main), outputUnitForElement(C)); 69 Expect.equals(outputUnitForElement(main), outputUnitForElement(C));
68 }); 70 });
69 await runTest('memory:main4.dart', (compiler) { 71 await runTest('memory:main4.dart', (compiler) {
70 var main = compiler.mainFunction; 72 var main = compiler.mainFunction;
71 Expect.isNotNull(main, "Could not find 'main'"); 73 Expect.isNotNull(main, "Could not find 'main'");
72 compiler.deferredLoadTask.onResolutionComplete(main); 74 compiler.deferredLoadTask.onResolutionComplete(
75 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
73 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 76 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
74 77
75 var mainLib = lookupLibrary(compiler, "memory:main4.dart"); 78 var mainLib = lookupLibrary(compiler, "memory:main4.dart");
76 var lib4 = lookupLibrary(compiler, "memory:lib4.dart"); 79 var lib4 = lookupLibrary(compiler, "memory:lib4.dart");
77 var lib5 = lookupLibrary(compiler, "memory:lib5.dart"); 80 var lib5 = lookupLibrary(compiler, "memory:lib5.dart");
78 var lib6 = lookupLibrary(compiler, "memory:lib6.dart"); 81 var lib6 = lookupLibrary(compiler, "memory:lib6.dart");
79 var foo5 = lib5.find("foo"); 82 var foo5 = lib5.find("foo");
80 var foo6 = lib6.find("foo"); 83 var foo6 = lib6.find("foo");
81 84
82 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo5)); 85 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo5));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 library lib5; 195 library lib5;
193 196
194 foo() {} 197 foo() {}
195 """, 198 """,
196 "lib6.dart": """ 199 "lib6.dart": """
197 library lib6; 200 library lib6;
198 201
199 foo() {} 202 foo() {}
200 """, 203 """,
201 }; 204 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698