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

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

Issue 646083002: dart2js: Fast fix for deferred globals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More comments. Created 6 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_dont_inline_deferred_globals_test.dart
diff --git a/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart b/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart
similarity index 51%
copy from tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
copy to tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart
index ae30c6b444ae5dbac5e9002bc0cd8368b4294dc7..8e9642af2172a82331398b9dce39dbc2cb8b9acf 100644
--- a/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
+++ b/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart
@@ -62,56 +62,18 @@ void main() {
var outputUnitForElement = compiler.deferredLoadTask.outputUnitForElement;
var lib1 = lookupLibrary("memory:lib1.dart");
- var foo1 = lib1.find("foo");
+ var foo1 = lib1.find("finalVar");
var ou_lib1 = outputUnitForElement(foo1);
- var lib2 = lookupLibrary("memory:lib2.dart");
- var foo2 = lib2.find("foo");
- var ou_lib2 = outputUnitForElement(foo2);
-
- var fooMain = compiler.mainApp.find("foo");
- var ou_lib1_lib2 = outputUnitForElement(fooMain);
-
String mainOutput = outputs["main.js"].mem.toString();
String lib1Output = outputs["out_${ou_lib1.name}.part.js"].mem.toString();
- String lib2Output = outputs["out_${ou_lib2.name}.part.js"].mem.toString();
- String lib12Output =
- outputs["out_${ou_lib1_lib2.name}.part.js"].mem.toString();
- // Test that the deferred constants are not inlined into the main file.
+ // Test that the deferred globals are not inlined into the main file.
RegExp re1 = new RegExp(r"= .string1");
RegExp re2 = new RegExp(r"= .string2");
- RegExp re3 = new RegExp(r"= 1010");
Expect.isTrue(re1.hasMatch(lib1Output));
Expect.isTrue(re2.hasMatch(lib1Output));
- Expect.isTrue(re3.hasMatch(lib1Output));
Expect.isFalse(re1.hasMatch(mainOutput));
Expect.isFalse(re2.hasMatch(mainOutput));
- Expect.isFalse(re3.hasMatch(mainOutput));
- // Test that the non-deferred constant is inlined.
- Expect.isTrue(new RegExp(r"print\(.string3.\)").hasMatch(mainOutput));
- Expect.isFalse(new RegExp(r"= .string3").hasMatch(mainOutput));
- Expect.isTrue(new RegExp(r"print\(.string4.\)").hasMatch(mainOutput));
-
- // C(1) is shared between main, lib1 and lib2. Test that lib1 and lib2 each
- // has a reference to it. It is defined in the main output file.
- Expect.isTrue(new RegExp(r"C.C_1 =").hasMatch(mainOutput));
- Expect.isFalse(new RegExp(r"= C.C_1").hasMatch(mainOutput));
-
- Expect.isTrue(new RegExp(r"= C.C_1").hasMatch(lib1Output));
- Expect.isTrue(new RegExp(r"= C.C_1").hasMatch(lib2Output));
-
- // C(2) is shared between lib1 and lib2, each of them has their own
- // reference to it.
- Expect.isFalse(new RegExp(r"= C.C_2").hasMatch(mainOutput));
-
- Expect.isTrue(new RegExp(r"= C.C_2").hasMatch(lib1Output));
- Expect.isTrue(new RegExp(r"= C.C_2").hasMatch(lib2Output));
- Expect.isTrue(new RegExp(r"C.C_2 =").hasMatch(lib12Output));
-
- // "string4" is shared between lib1 and lib2, but it can be inlined.
- Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib1Output));
- Expect.isTrue(new RegExp(r"= .string4").hasMatch(lib2Output));
- Expect.isFalse(new RegExp(r"= .string4").hasMatch(lib12Output));
}));
}
@@ -120,58 +82,17 @@ const Map MEMORY_SOURCE_FILES = const {"main.dart": """
import "dart:async";
import 'lib1.dart' deferred as lib1;
-import 'lib2.dart' deferred as lib2;
-
-const c = "string3";
-
-class C {
- final p;
- const C(this.p);
-}
-
-foo() => print("main");
void main() {
lib1.loadLibrary().then((_) {
- lib2.loadLibrary().then((_) {
- lib1.foo();
- lib2.foo();
- print(lib1.C1);
- print(lib1.C2);
- print(lib1.C.C3);
- print(c);
- print(lib1.C4);
- print(lib2.C4);
- print(lib1.C5);
- print(lib2.C5);
- print(lib1.C6);
- print(lib2.C6);
- print("string4");
- print(const C(1));
- });
+ print(lib1.finalVar);
+ print(lib1.globalVar);
+ lib1.globalVar = "foobar";
+ print(lib1.globalVar);
});
}
""", "lib1.dart": """
import "main.dart" as main;
-const C1 = "string1";
-const C2 = 1010;
-class C {
- static const C3 = "string2";
-}
-const C4 = "string4";
-const C5 = const main.C(1);
-const C6 = const main.C(2);
-foo() {
- print("lib1");
- main.foo();
-}
-""", "lib2.dart": """
-import "main.dart" as main;
-const C4 = "string4";
-const C5 = const main.C(1);
-const C6 = const main.C(2);
-foo() {
- print("lib2");
- main.foo();
-}
+final finalVar = "string1";
+var globalVar = "string2";
"""};

Powered by Google App Engine
This is Rietveld 408576698