| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #import('dart:uri'); | 5 #import('dart:uri'); |
| 6 #import('parser_helper.dart'); | 6 #import('parser_helper.dart'); |
| 7 #import('mock_compiler.dart'); | 7 #import('mock_compiler.dart'); |
| 8 #import("../../../lib/compiler/compiler.dart"); | 8 #import("../../../lib/compiler/compiler.dart"); |
| 9 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); | 9 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); |
| 10 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 10 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 interface List {} | 32 interface List {} |
| 33 interface Closure {} | 33 interface Closure {} |
| 34 interface Dynamic {} | 34 interface Dynamic {} |
| 35 interface Null {} | 35 interface Null {} |
| 36 assert() {} | 36 assert() {} |
| 37 class Math { | 37 class Math { |
| 38 static double parseDouble(String s) => 1.0; | 38 static double parseDouble(String s) => 1.0; |
| 39 } | 39 } |
| 40 '''; | 40 '''; |
| 41 | 41 |
| 42 final ioLib = @''' |
| 43 #library('io'); |
| 44 class Platform { |
| 45 static int operatingSystem; |
| 46 } |
| 47 '''; |
| 48 |
| 42 testDart2Dart(String src, [void continuation(String s)]) { | 49 testDart2Dart(String src, [void continuation(String s)]) { |
| 43 // If continuation is not provided, check that source string remains the same. | 50 // If continuation is not provided, check that source string remains the same. |
| 44 if (continuation === null) { | 51 if (continuation === null) { |
| 45 continuation = (s) { Expect.equals(src, s); }; | 52 continuation = (s) { Expect.equals(src, s); }; |
| 46 } | 53 } |
| 47 testDart2DartWithLibrary(src, '', continuation); | 54 testDart2DartWithLibrary(src, '', continuation); |
| 48 } | 55 } |
| 49 | 56 |
| 50 /** | 57 /** |
| 51 * Library name is assumed to be 'mylib' in 'mylib.dart' file. | 58 * Library name is assumed to be 'mylib' in 'mylib.dart' file. |
| 52 */ | 59 */ |
| 53 testDart2DartWithLibrary( | 60 testDart2DartWithLibrary( |
| 54 String srcMain, String srcLibrary, [void continuation(String s)]) { | 61 String srcMain, String srcLibrary, [void continuation(String s)]) { |
| 55 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); | 62 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); |
| 56 | 63 |
| 57 final scriptUri = fileUri('script.dart'); | 64 final scriptUri = fileUri('script.dart'); |
| 58 final libUri = fileUri('mylib.dart'); | 65 final libUri = fileUri('mylib.dart'); |
| 59 | 66 |
| 60 provider(uri) { | 67 provider(uri) { |
| 61 if (uri == scriptUri) return new Future.immediate(srcMain); | 68 if (uri == scriptUri) return new Future.immediate(srcMain); |
| 62 if (uri.toString() == libUri.toString()) { | 69 if (uri.toString() == libUri.toString()) { |
| 63 return new Future.immediate(srcLibrary); | 70 return new Future.immediate(srcLibrary); |
| 64 } | 71 } |
| 65 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); | 72 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); |
| 73 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib); |
| 66 return new Future.immediate(''); | 74 return new Future.immediate(''); |
| 67 } | 75 } |
| 68 | 76 |
| 69 handler(uri, begin, end, message, kind) { | 77 handler(uri, begin, end, message, kind) { |
| 70 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) { | 78 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) { |
| 71 Expect.fail('$uri: $begin-$end: $message [$kind]'); | 79 Expect.fail('$uri: $begin-$end: $message [$kind]'); |
| 72 } | 80 } |
| 73 } | 81 } |
| 74 | 82 |
| 75 compile( | 83 compile( |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 631 } |
| 624 '''; | 632 '''; |
| 625 var expectedResult = | 633 var expectedResult = |
| 626 'class C<T>{factory I(){}}' | 634 'class C<T>{factory I(){}}' |
| 627 'interface I<T> default C<T>{I();}' | 635 'interface I<T> default C<T>{I();}' |
| 628 'main(){new I();}'; | 636 'main(){new I();}'; |
| 629 testDart2DartWithLibrary(mainSrc, librarySrc, | 637 testDart2DartWithLibrary(mainSrc, librarySrc, |
| 630 (String result) { Expect.equals(expectedResult, result); }); | 638 (String result) { Expect.equals(expectedResult, result); }); |
| 631 } | 639 } |
| 632 | 640 |
| 641 testStaticAccessIoLib() { |
| 642 var src = ''' |
| 643 #import('dart:io'); |
| 644 |
| 645 main() { |
| 646 Platform.operatingSystem; |
| 647 } |
| 648 '''; |
| 649 var expectedResult = '#import("dart:io", prefix: "p");' |
| 650 'main(){p.Platform.operatingSystem;}'; |
| 651 testDart2Dart(src, |
| 652 (String result) { Expect.equals(expectedResult, result); }); |
| 653 } |
| 654 |
| 633 main() { | 655 main() { |
| 634 testSignedConstants(); | 656 testSignedConstants(); |
| 635 testGenericTypes(); | 657 testGenericTypes(); |
| 636 testForLoop(); | 658 testForLoop(); |
| 637 testEmptyList(); | 659 testEmptyList(); |
| 638 testClosure(); | 660 testClosure(); |
| 639 testIndexedOperatorDecl(); | 661 testIndexedOperatorDecl(); |
| 640 testNativeMethods(); | 662 testNativeMethods(); |
| 641 testPrefixIncrements(); | 663 testPrefixIncrements(); |
| 642 testConstModifier(); | 664 testConstModifier(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 658 testClassExtendsWithArgs(); | 680 testClassExtendsWithArgs(); |
| 659 testStaticInvocation(); | 681 testStaticInvocation(); |
| 660 testLibraryGetSet(); | 682 testLibraryGetSet(); |
| 661 testFieldTypeOutput(); | 683 testFieldTypeOutput(); |
| 662 testDefaultClassNamePlaceholder(); | 684 testDefaultClassNamePlaceholder(); |
| 663 testFactoryRename(); | 685 testFactoryRename(); |
| 664 testTypeVariablesAreRenamed(); | 686 testTypeVariablesAreRenamed(); |
| 665 testClassTypeArgumentBound(); | 687 testClassTypeArgumentBound(); |
| 666 testDoubleMains(); | 688 testDoubleMains(); |
| 667 testInterfaceDefaultAnotherLib(); | 689 testInterfaceDefaultAnotherLib(); |
| 690 testStaticAccessIoLib(); |
| 668 } | 691 } |
| OLD | NEW |