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

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

Issue 1299413002: Move common identifiers, names and selectors to a separate library. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 12 matching lines...) Expand all
23 lookupLibrary(compiler, name) { 23 lookupLibrary(compiler, name) {
24 return compiler.libraryLoader.lookupLibrary(Uri.parse(name)); 24 return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
25 } 25 }
26 26
27 void main() { 27 void main() {
28 asyncTest(runTests); 28 asyncTest(runTests);
29 } 29 }
30 30
31 runTests() async { 31 runTests() async {
32 await runTest('memory:main.dart', (compiler) { 32 await runTest('memory:main.dart', (compiler) {
33 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 33 var main = compiler.mainFunction;
34 Expect.isNotNull(main, "Could not find 'main'"); 34 Expect.isNotNull(main, "Could not find 'main'");
35 compiler.deferredLoadTask.onResolutionComplete(main); 35 compiler.deferredLoadTask.onResolutionComplete(main);
36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 36 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
37 37
38 var lib1 = lookupLibrary(compiler, "memory:lib1.dart"); 38 var lib1 = lookupLibrary(compiler, "memory:lib1.dart");
39 var lib2 = lookupLibrary(compiler, "memory:lib2.dart"); 39 var lib2 = lookupLibrary(compiler, "memory:lib2.dart");
40 var mathLib = lookupLibrary(compiler, "dart:math"); 40 var mathLib = lookupLibrary(compiler, "dart:math");
41 var sin = mathLib.find('sin'); 41 var sin = mathLib.find('sin');
42 var foo1 = lib1.find("foo1"); 42 var foo1 = lib1.find("foo1");
43 var foo2 = lib2.find("foo2"); 43 var foo2 = lib2.find("foo2");
44 var field2 = lib2.find("field2"); 44 var field2 = lib2.find("field2");
45 45
46 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1)); 46 Expect.notEquals(outputUnitForElement(main), outputUnitForElement(foo1));
47 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin)); 47 Expect.equals(outputUnitForElement(main), outputUnitForElement(sin));
48 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2)); 48 Expect.equals(outputUnitForElement(foo2), outputUnitForElement(field2));
49 }); 49 });
50 await runTest('memory:main2.dart', (compiler) { 50 await runTest('memory:main2.dart', (compiler) {
51 // Just check that the compile runs. 51 // Just check that the compile runs.
52 // This is a regression test. 52 // This is a regression test.
53 Expect.isTrue(true); 53 Expect.isTrue(true);
54 }); 54 });
55 await runTest('memory:main3.dart', (compiler) { 55 await runTest('memory:main3.dart', (compiler) {
56 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 56 var main = compiler.mainFunction;
57 Expect.isNotNull(main, "Could not find 'main'"); 57 Expect.isNotNull(main, "Could not find 'main'");
58 compiler.deferredLoadTask.onResolutionComplete(main); 58 compiler.deferredLoadTask.onResolutionComplete(main);
59 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 59 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
60 60
61 Expect.isFalse(compiler.backend.hasInsufficientMirrorsUsed); 61 Expect.isFalse(compiler.backend.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(outputUnitForElement(main), outputUnitForElement(foo));
68 Expect.equals(outputUnitForElement(main), outputUnitForElement(C)); 68 Expect.equals(outputUnitForElement(main), outputUnitForElement(C));
69 }); 69 });
70 await runTest('memory:main4.dart', (compiler) { 70 await runTest('memory:main4.dart', (compiler) {
71 var main = compiler.mainApp.find(dart2js.Compiler.MAIN); 71 var main = compiler.mainFunction;
72 Expect.isNotNull(main, "Could not find 'main'"); 72 Expect.isNotNull(main, "Could not find 'main'");
73 compiler.deferredLoadTask.onResolutionComplete(main); 73 compiler.deferredLoadTask.onResolutionComplete(main);
74 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement; 74 var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
75 75
76 var mainLib = lookupLibrary(compiler, "memory:main4.dart"); 76 var mainLib = lookupLibrary(compiler, "memory:main4.dart");
77 var lib4 = lookupLibrary(compiler, "memory:lib4.dart"); 77 var lib4 = lookupLibrary(compiler, "memory:lib4.dart");
78 var lib5 = lookupLibrary(compiler, "memory:lib5.dart"); 78 var lib5 = lookupLibrary(compiler, "memory:lib5.dart");
79 var lib6 = lookupLibrary(compiler, "memory:lib6.dart"); 79 var lib6 = lookupLibrary(compiler, "memory:lib6.dart");
80 var foo5 = lib5.find("foo"); 80 var foo5 = lib5.find("foo");
81 var foo6 = lib6.find("foo"); 81 var foo6 = lib6.find("foo");
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 library lib5; 193 library lib5;
194 194
195 foo() {} 195 foo() {}
196 """, 196 """,
197 "lib6.dart": """ 197 "lib6.dart": """
198 library lib6; 198 library lib6;
199 199
200 foo() {} 200 foo() {}
201 """, 201 """,
202 }; 202 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698