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

Unified Diff: tests/compiler/dart2js/deferred_not_in_main_test.dart

Issue 1395183004: dart2js: mark FunctionElements as dependencies always (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/deferred_not_in_main_test.dart
diff --git a/tests/compiler/dart2js/deferred_not_in_main_test.dart b/tests/compiler/dart2js/deferred_not_in_main_test.dart
index 80f2a230f9ddc31ea255754225a4404548aa80c7..2955879efcd3d0148da923ba04c0dd61c0f43633 100644
--- a/tests/compiler/dart2js/deferred_not_in_main_test.dart
+++ b/tests/compiler/dart2js/deferred_not_in_main_test.dart
@@ -12,9 +12,14 @@ import 'package:expect/expect.dart';
import 'memory_compiler.dart';
void main() {
+ deferredTest1();
+ deferredTest2();
+}
+
+void deferredTest1() {
asyncTest(() async {
CompilationResult result =
- await runCompiler(memorySourceFiles: MEMORY_SOURCE_FILES);
+ await runCompiler(memorySourceFiles: TEST1);
Compiler compiler = result.compiler;
lookupLibrary(name) {
@@ -26,7 +31,6 @@ void main() {
var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
var backend = compiler.backend;
- var classes = backend.emitter.neededClasses;
var lib1 = lookupLibrary("memory:lib1.dart");
var lib2 = lookupLibrary("memory:lib2.dart");
var foo1 = lib1.find("foo1");
@@ -36,9 +40,29 @@ void main() {
});
}
+void deferredTest2() {
+ asyncTest(() async {
+ CompilationResult result = await runCompiler(memorySourceFiles: TEST2);
+ Compiler compiler = result.compiler;
+
+ lookupLibrary(name) {
+ return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
+ }
+
+ var main = compiler.mainFunction;
+ var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
+
+ var mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit;
+ var shared = lookupLibrary("memory:shared.dart");
+ var a = shared.find("A");
+
+ Expect.equals(mainOutputUnit, outputUnitForElement(a));
+ });
+}
+
// lib1 imports lib2 deferred. But mainlib never uses DeferredLibrary.
// Test that this case works.
-const Map MEMORY_SOURCE_FILES = const {
+const Map TEST1 = const {
"main.dart":"""
library mainlib;
@@ -65,3 +89,31 @@ library lib2;
void foo2() {}
""",
};
+
+// main indirectly uses class A from shared. A should still be included in the
+// main fragment.
+const Map TEST2 = const {
+ "main.dart":"""
+import 'def.dart' deferred as def;
+import 'shared.dart';
+
+typedef void F(x);
+
+main() {
+ print(foo is F);
+ def.loadLibrary().then((_) {
+ def.toto();
+ });
+}
+""",
+ "def.dart":"""
+import 'shared.dart';
+
+toto() { print(new A()); }
+""",
+ "shared.dart":"""
+class A {}
+class B extends A {}
+foo(B b) => null;
+""",
+};
« pkg/compiler/lib/src/deferred_load.dart ('K') | « pkg/compiler/lib/src/deferred_load.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698