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

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

Issue 10990053: [dart2dart] Force-compile top-level elements in libraries to get local members correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/dart_backend_test.dart
diff --git a/tests/compiler/dart2js/dart_backend_test.dart b/tests/compiler/dart2js/dart_backend_test.dart
index b19645e42f35779fbbaad1b066d77fc97f442f40..cddaccace968a71a058aa9061f679e444c13ee42 100644
--- a/tests/compiler/dart2js/dart_backend_test.dart
+++ b/tests/compiler/dart2js/dart_backend_test.dart
@@ -38,6 +38,18 @@ class Platform {
}
''';
+const htmlLib = r'''
+#library('html');
+Window __window;
+Window get window() => __window;
+abstract class Window {
+ abstract Navigator get navigator;
+}
+abstract class Navigator {
+ abstract String get userAgent;
+}
+''';
+
testDart2Dart(String src, [void continuation(String s), bool minify = false,
bool cutDeclarationTypes = false]) {
// If continuation is not provided, check that source string remains the same.
@@ -66,6 +78,8 @@ testDart2DartWithLibrary(
}
if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib);
if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib);
+ // TODO(smok): The file should change to html_dartium at some point.
+ if (uri.path.endsWith('/html_dart2js.dart')) return new Future.immediate(htmlLib);
return new Future.immediate('');
}
@@ -741,6 +755,25 @@ main() {
cutDeclarationTypes: true);
}
+testPlatformLibraryMemberNamesAreFixed() {
+ var src = '''
+#import('dart:html');
+
+class A {
+ static String get userAgent => window.navigator.userAgent;
+}
+
+main() {
+ A.userAgent;
+}
+''';
+ var expectedResult = '#import("dart:html",prefix:"p");'
+ 'class A{static String get userAgent=>p.window.navigator.userAgent;}'
+ 'main(){A.userAgent;}';
+ testDart2Dart(src,
+ (String result) { Expect.equals(expectedResult, result); });
+}
+
main() {
testSimpleFileUnparse();
testTopLevelField();
@@ -773,4 +806,5 @@ main() {
testParametersMinified();
testTypeVariablesInDifferentLibraries();
testDeclarationTypePlaceholders();
+ testPlatformLibraryMemberNamesAreFixed();
}

Powered by Google App Engine
This is Rietveld 408576698