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

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..5aca14d403b1760206a30d7f4165c1676f8cfca1 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -63,6 +63,37 @@ testDart2Dart(String src, [void continuation(String s)]) {
const ['--output-type=dart', '--unparse-validation']).then(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);
Anton Muhin 2012/07/23 11:23:10 looks like a lot of code duplication w/ testDart2D
Roman 2012/07/23 15:34:15 Done.
+
+ final scriptUri = fileUri('script.dart');
+ final libUri = fileUri('mylib.dart');
+
+ provider(uri) {
+ 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('');
+ }
+
+ handler(uri, begin, end, message, kind) {
+ if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) {
+ Expect.fail('$uri: $begin-$end: $message [$kind]');
+ }
+ }
+
+ compile(
+ scriptUri,
+ fileUri('libraryRoot'),
+ fileUri('packageRoot'),
+ provider,
+ handler,
+ const ['--output-type=dart', '--unparse-validation']).then(continuation);
+}
+
testGenericTypes() {
testUnparse('var x=new List<List<int>>();');
testUnparse('var x=new List<List<List<int>>>();');
@@ -194,6 +225,54 @@ 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() {
Anton Muhin 2012/07/23 11:23:10 nit: => syntax, please
Roman 2012/07/23 15:34:15 Done.
+ return 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(){return 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 +291,5 @@ main() {
testGetSet();
testFactoryConstructor();
testTopLevelField();
+ testConflictLibraryClassRename();
}

Powered by Google App Engine
This is Rietveld 408576698