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

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

Issue 356573002: Revert "Move Compiler.libraries to LibraryLoder." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
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:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
11 import 'memory_source_file_helper.dart'; 11 import 'memory_source_file_helper.dart';
12 import "memory_compiler.dart"; 12 import "memory_compiler.dart";
13 13
14 import 'package:compiler/implementation/dart2jslib.dart' 14 import 'package:compiler/implementation/dart2jslib.dart'
15 as dart2js; 15 as dart2js;
16 16
17 runTest(String mainScript, test) { 17 runTest(String mainScript, test) {
18 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES, 18 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES,
19 outputProvider: new OutputCollector()); 19 outputProvider: new OutputCollector());
20 asyncTest(() => compiler.run(Uri.parse(mainScript)) 20 asyncTest(() => compiler.run(Uri.parse(mainScript))
21 .then((_) => test(compiler))); 21 .then((_) => test(compiler)));
22 } 22 }
23 23
24 lookupLibrary(compiler, name) {
25 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
26 }
27
28 void main() { 24 void main() {
29 runTest('memory:main.dart', (compiler) { 25 runTest('memory:main.dart', (compiler) {
30 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 26 var main = compiler.mainApp.find(dart2js.Compiler.MAIN);
31 Expect.isNotNull(main, "Could not find 'main'"); 27 Expect.isNotNull(main, "Could not find 'main'");
32 compiler.deferredLoadTask.onResolutionComplete(main); 28 compiler.deferredLoadTask.onResolutionComplete(main);
33 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 29 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
34 30
35 var lib1 = lookupLibrary(compiler, "memory:lib1.dart"); 31 var lib1 = compiler.libraries["memory:lib1.dart"];
36 var lib2 = lookupLibrary(compiler, "memory:lib2.dart"); 32 var lib2 = compiler.libraries["memory:lib2.dart"];
37 var mathLib = lookupLibrary(compiler, "dart:math"); 33 var mathLib = compiler.libraries["dart:math"];
38 var sin = mathLib.find('sin'); 34 var sin = mathLib.find('sin');
39 var foo1 = lib1.find("foo1"); 35 var foo1 = lib1.find("foo1");
40 var foo2 = lib2.find("foo2"); 36 var foo2 = lib2.find("foo2");
41 var field2 = lib2.find("field2"); 37 var field2 = lib2.find("field2");
42 38
43 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1)); 39 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1));
44 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin)); 40 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin));
45 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2)); 41 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2));
46 }); 42 });
47 runTest('memory:main2.dart', (compiler) { 43 runTest('memory:main2.dart', (compiler) {
48 // Just check that the compile runs. 44 // Just check that the compile runs.
49 // This is a regression test. 45 // This is a regression test.
50 Expect.isTrue(true); 46 Expect.isTrue(true);
51 }); 47 });
52 runTest('memory:main3.dart', (compiler) { 48 runTest('memory:main3.dart', (compiler) {
53 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 49 var main = compiler.mainApp.find(dart2js.Compiler.MAIN);
54 Expect.isNotNull(main, "Could not find 'main'"); 50 Expect.isNotNull(main, "Could not find 'main'");
55 compiler.deferredLoadTask.onResolutionComplete(main); 51 compiler.deferredLoadTask.onResolutionComplete(main);
56 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 52 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
57 53
58 var mainLib = lookupLibrary(compiler, "memory:main3.dart"); 54 var mainLib = compiler.libraries["memory:main3.dart"];
59 var lib3 = lookupLibrary(compiler, "memory:lib3.dart"); 55 var lib3 = compiler.libraries["memory:lib3.dart"];
60 var C = mainLib.find("C"); 56 var C = mainLib.find("C");
61 var foo = lib3.find("foo"); 57 var foo = lib3.find("foo");
62 58
63 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo)); 59 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo));
64 Expect.equals(outputUnitForElement(main), outputUnitForElement(C)); 60 Expect.equals(outputUnitForElement(main), outputUnitForElement(C));
65 }); 61 });
66 runTest('memory:main4.dart', (compiler) { 62 runTest('memory:main4.dart', (compiler) {
67 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 63 var main = compiler.mainApp.find(dart2js.Compiler.MAIN);
68 Expect.isNotNull(main, "Could not find 'main'"); 64 Expect.isNotNull(main, "Could not find 'main'");
69 compiler.deferredLoadTask.onResolutionComplete(main); 65 compiler.deferredLoadTask.onResolutionComplete(main);
70 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 66 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
71 67
72 var mainLib = lookupLibrary(compiler, "memory:main4.dart"); 68 var mainLib = compiler.libraries["memory:main4.dart"];
73 var lib4 = lookupLibrary(compiler, "memory:lib4.dart"); 69 var lib4 = compiler.libraries["memory:lib4.dart"];
74 var lib5 = lookupLibrary(compiler, "memory:lib5.dart"); 70 var lib5 = compiler.libraries["memory:lib5.dart"];
75 var lib6 = lookupLibrary(compiler, "memory:lib6.dart"); 71 var lib6 = compiler.libraries["memory:lib6.dart"];
76 var foo5 = lib5.find("foo"); 72 var foo5 = lib5.find("foo");
77 var foo6 = lib6.find("foo"); 73 var foo6 = lib6.find("foo");
78 74
79 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo5)); 75 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo5));
80 Expect.equals(outputUnitForElement(foo5), outputUnitForElement(foo6)); 76 Expect.equals(outputUnitForElement(foo5), outputUnitForElement(foo6));
81 }); 77 });
82 } 78 }
83 79
84 // "lib1.dart" uses mirrors without a MirrorsUsed annotation, so everything 80 // "lib1.dart" uses mirrors without a MirrorsUsed annotation, so everything
85 // should be put in the "lib1" output unit. 81 // should be put in the "lib1" output unit.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 library lib5; 185 library lib5;
190 186
191 foo() {} 187 foo() {}
192 """, 188 """,
193 "lib6.dart": """ 189 "lib6.dart": """
194 library lib6; 190 library lib6;
195 191
196 foo() {} 192 foo() {}
197 """, 193 """,
198 }; 194 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698