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

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

Issue 10861029: Properly rename type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/unparser_test.dart
diff --git a/tests/compiler/dart2js/unparser_test.dart b/tests/compiler/dart2js/unparser_test.dart
index b0c79e33be033d3090abc4e781c3ed56e12694fe..6c1fdee4eee9c5df4d106305e5eafa46f5b4a9d9 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -513,6 +513,39 @@ main() {
(String result) { Expect.equals(expectedResult, result); });
}
+testTypeVariablesAreRenamed() {
+ // Somewhat a hack: we require all the references of the identifier
+ // to be renamed in the same way for the whole library. Hence
+ // if we have a class and type variable with the same name, they
+ // both should be renamed.
+ var librarySrc = '''
+#library('mylib');
+class T {}
+class B<T> {}
+class A<T> extends B<T> { T f; }
+''';
+ var mainSrc = '''
+#import('mylib.dart', prefix: 'mylib');
+class T {}
+class B<T> {}
+class A<T> extends B<T> { T f; }
+
+main() {
+ new A<int>().f;
+ new T();
+
+ new mylib.A<int>().f;
+ new mylib.T();
+}
+''';
+ var expectedResult =
+ 'class T{}class B<T>{}class A<T> extends B<T>{T f;}'
+ 'class p_T{}class p_B<p_T>{}class p_A<p_T> extends p_B<p_T>{p_T f;}'
+ 'main(){new p_A<int>().f; new p_T(); new A<int>().f; new T();}';
+ testDart2DartWithLibrary(mainSrc, librarySrc,
+ (String result) { Expect.equals(expectedResult, result); });
+}
+
main() {
testSignedConstants();
testGenericTypes();
@@ -544,4 +577,5 @@ main() {
testFieldTypeOutput();
testDefaultClassNamePlaceholder();
testFactoryRename();
+ testTypeVariablesAreRenamed();
}

Powered by Google App Engine
This is Rietveld 408576698