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

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

Issue 3008793002: Use the entity model for dump_info. (Closed)
Patch Set: use codegen enqueuer Created 3 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 'dart:async'; 9 import 'dart:async';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 14 matching lines...) Expand all
25 void main() { 25 void main() {
26 asyncTest(runTests); 26 asyncTest(runTests);
27 } 27 }
28 28
29 runTests() async { 29 runTests() async {
30 await runTest('memory:main.dart', (compiler) { 30 await runTest('memory:main.dart', (compiler) {
31 var main = compiler.frontendStrategy.elementEnvironment.mainFunction; 31 var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
32 Expect.isNotNull(main, "Could not find 'main'"); 32 Expect.isNotNull(main, "Could not find 'main'");
33 compiler.deferredLoadTask.onResolutionComplete( 33 compiler.deferredLoadTask.onResolutionComplete(
34 main, compiler.resolutionWorldBuilder.closedWorldForTesting); 34 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
35 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 35 var outputUnitForEntity = compiler.deferredLoadTask.outputUnitForEntity;
36 36
37 var lib1 = lookupLibrary(compiler, "memory:lib1.dart"); 37 var lib1 = lookupLibrary(compiler, "memory:lib1.dart");
38 var lib2 = lookupLibrary(compiler, "memory:lib2.dart"); 38 var lib2 = lookupLibrary(compiler, "memory:lib2.dart");
39 var mathLib = lookupLibrary(compiler, "dart:math"); 39 var mathLib = lookupLibrary(compiler, "dart:math");
40 var sin = mathLib.find('sin'); 40 var sin = mathLib.find('sin');
41 var foo1 = lib1.find("foo1"); 41 var foo1 = lib1.find("foo1");
42 var foo2 = lib2.find("foo2"); 42 var foo2 = lib2.find("foo2");
43 var field2 = lib2.find("field2"); 43 var field2 = lib2.find("field2");
44 44
45 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1)); 45 Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo1));
46 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin)); 46 Expect.equals(outputUnitForEntity(main), outputUnitForEntity(sin));
47 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2)); 47 Expect.equals(outputUnitForEntity(foo2), outputUnitForEntity(field2));
48 }); 48 });
49 await runTest('memory:main2.dart', (compiler) { 49 await runTest('memory:main2.dart', (compiler) {
50 // Just check that the compile runs. 50 // Just check that the compile runs.
51 // This is a regression test. 51 // This is a regression test.
52 Expect.isTrue(true); 52 Expect.isTrue(true);
53 }); 53 });
54 await runTest('memory:main3.dart', (compiler) { 54 await runTest('memory:main3.dart', (compiler) {
55 var main = compiler.frontendStrategy.elementEnvironment.mainFunction; 55 var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
56 Expect.isNotNull(main, "Could not find 'main'"); 56 Expect.isNotNull(main, "Could not find 'main'");
57 compiler.deferredLoadTask.onResolutionComplete( 57 compiler.deferredLoadTask.onResolutionComplete(
58 main, compiler.resolutionWorldBuilder.closedWorldForTesting); 58 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
59 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 59 var outputUnitForEntity = compiler.deferredLoadTask.outputUnitForEntity;
60 60
61 Expect.isFalse(compiler.backend.mirrorsData.hasInsufficientMirrorsUsed); 61 Expect.isFalse(compiler.backend.mirrorsData.hasInsufficientMirrorsUsed);
62 var mainLib = lookupLibrary(compiler, "memory:main3.dart"); 62 var mainLib = lookupLibrary(compiler, "memory:main3.dart");
63 var lib3 = lookupLibrary(compiler, "memory:lib3.dart"); 63 var lib3 = lookupLibrary(compiler, "memory:lib3.dart");
64 var C = mainLib.find("C"); 64 var C = mainLib.find("C");
65 var foo = lib3.find("foo"); 65 var foo = lib3.find("foo");
66 66
67 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo)); 67 Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo));
68 Expect.equals(outputUnitForElement(main), outputUnitForElement(C)); 68 Expect.equals(outputUnitForEntity(main), outputUnitForEntity(C));
69 }); 69 });
70 await runTest('memory:main4.dart', (compiler) { 70 await runTest('memory:main4.dart', (compiler) {
71 var main = compiler.frontendStrategy.elementEnvironment.mainFunction; 71 var main = compiler.frontendStrategy.elementEnvironment.mainFunction;
72 Expect.isNotNull(main, "Could not find 'main'"); 72 Expect.isNotNull(main, "Could not find 'main'");
73 compiler.deferredLoadTask.onResolutionComplete( 73 compiler.deferredLoadTask.onResolutionComplete(
74 main, compiler.resolutionWorldBuilder.closedWorldForTesting); 74 main, compiler.resolutionWorldBuilder.closedWorldForTesting);
75 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 75 var outputUnitForEntity = compiler.deferredLoadTask.outputUnitForEntity;
76 76
77 lookupLibrary(compiler, "memory:main4.dart"); 77 lookupLibrary(compiler, "memory:main4.dart");
78 lookupLibrary(compiler, "memory:lib4.dart"); 78 lookupLibrary(compiler, "memory:lib4.dart");
79 var lib5 = lookupLibrary(compiler, "memory:lib5.dart"); 79 var lib5 = lookupLibrary(compiler, "memory:lib5.dart");
80 var lib6 = lookupLibrary(compiler, "memory:lib6.dart"); 80 var lib6 = lookupLibrary(compiler, "memory:lib6.dart");
81 var foo5 = lib5.find("foo"); 81 var foo5 = lib5.find("foo");
82 var foo6 = lib6.find("foo"); 82 var foo6 = lib6.find("foo");
83 83
84 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo5)); 84 Expect.notEquals(outputUnitForEntity(main), outputUnitForEntity(foo5));
85 Expect.equals(outputUnitForElement(foo5), outputUnitForElement(foo6)); 85 Expect.equals(outputUnitForEntity(foo5), outputUnitForEntity(foo6));
86 }); 86 });
87 } 87 }
88 88
89 // "lib1.dart" uses mirrors without a MirrorsUsed annotation, so everything 89 // "lib1.dart" uses mirrors without a MirrorsUsed annotation, so everything
90 // should be put in the "lib1" output unit. 90 // should be put in the "lib1" output unit.
91 const Map MEMORY_SOURCE_FILES = const { 91 const Map MEMORY_SOURCE_FILES = const {
92 "main.dart": """ 92 "main.dart": """
93 import "dart:math"; 93 import "dart:math";
94 94
95 import 'lib1.dart' deferred as lib1; 95 import 'lib1.dart' deferred as lib1;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 library lib5; 194 library lib5;
195 195
196 foo() {} 196 foo() {}
197 """, 197 """,
198 "lib6.dart": """ 198 "lib6.dart": """
199 library lib6; 199 library lib6;
200 200
201 foo() {} 201 foo() {}
202 """, 202 """,
203 }; 203 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698