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

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

Issue 10795064: dart2dart: Introduce Renamer that is used by renaming unparser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 7b97f8bd20b06c3b6351cff72a6400c1e707d420..faa57f85b7e320d6558b9b5a2c6d22a639cd8662 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -34,12 +34,25 @@ assert() {}
''';
testDart2Dart(String src, [void continuation(String s)]) {
+ // If continuation is not provided, check that source string remains the same.
+ if (continuation === null) {
+ continuation = (s) { Expect.equals(src, s); };
+ }
+ testDart2DartWithLibrary(src, '', continuation);
+}
+
+/**
+ * Library name is assumed to be 'mylib' in 'mylib.dart' file.
+ */
+testDart2DartWithLibrary(String srcMain, String srcLibrary, [void continuation(String s)]) {
fileUri(path) => new Uri(scheme: 'file', path: path);
final scriptUri = fileUri('script.dart');
+ final libUri = fileUri('mylib.dart');
provider(uri) {
- if (uri == scriptUri) return new Future.immediate(src);
+ if (uri == scriptUri) return new Future.immediate(srcMain);
+ if (uri.toString() == libUri.toString()) return new Future.immediate(srcLibrary);
if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib);
return new Future.immediate('');
}
@@ -50,10 +63,6 @@ testDart2Dart(String src, [void continuation(String s)]) {
}
}
- // If continuation is not provided, check that source string remains the same.
- if (continuation == null) {
- continuation = (s) => Expect.equals(src, s);
- }
compile(
scriptUri,
fileUri('libraryRoot'),
@@ -194,6 +203,52 @@ testFactoryConstructor() {
'final String f;}');
}
+testConflictLibraryClassRename() {
+ var librarySrc = '''
+#library('mylib');
+
+topfoo() {}
+
+class A {
+ foo(){}
+}
+''';
+ var mainSrc = '''
+#import('mylib.dart', prefix: 'mylib');
+
+
+topfoo() {var x = 5;}
+
+class A{
+ num foo() {}
+ A.fromFoo() {}
+ mylib.A myliba;
+ List<A> mylist;
+}
+
+mylib.A getA() => null;
+
+main() {
+ var a = new mylib.A();
+ a.foo();
+ var b = new A.fromFoo();
+ b.foo();
+ var GREATVAR = b.myliba;
+ b.mylist;
+ a = getA();
+ topfoo();
+ mylib.topfoo();
+}
+''';
+ var expectedResult = 'topfoo(){}_topfoo(){var x=5;}A getA()=> null;'
+ 'main(){var a=new A(); a.foo(); var b=new _A.fromFoo(); b.foo(); '
+ 'var GREATVAR=b.myliba; b.mylist; a=getA(); _topfoo(); topfoo();}'
+ 'class _A{_A.fromFoo(){}List<List> mylist;num foo(){}A myliba;}'
+ 'class A{foo(){}}';
+ testDart2DartWithLibrary(mainSrc, librarySrc,
+ (String result) { Expect.equals(expectedResult, result); });
+}
+
main() {
testGenericTypes();
testForLoop();
@@ -212,4 +267,5 @@ main() {
testGetSet();
testFactoryConstructor();
testTopLevelField();
+ testConflictLibraryClassRename();
}
« lib/compiler/implementation/resolver.dart ('K') | « lib/compiler/implementation/tree/unparser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698