Chromium Code Reviews| 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..dc2095e63f935c2630c46807660046ac879ae904 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) { |
|
Anton Muhin
2012/07/23 17:01:27
nit: === null
Roman
2012/07/23 17:38:33
Done.
|
| + continuation = (s) => Expect.equals(src, s); |
|
Anton Muhin
2012/07/23 17:01:27
technically, it should be warning as Expect.equals
Roman
2012/07/23 17:38:33
Changed to (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(); |
| } |