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

Side by Side Diff: tests/compiler/dart2js/unparser_test.dart

Issue 10891004: [dart2dart] Optionally cut types in variable declarations: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/leg.dart", prefix:'leg'); 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg');
10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart");
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 '''; 41 ''';
42 42
43 const ioLib = @''' 43 const ioLib = @'''
44 #library('io'); 44 #library('io');
45 class Platform { 45 class Platform {
46 static int operatingSystem; 46 static int operatingSystem;
47 } 47 }
48 '''; 48 ''';
49 49
50 testDart2Dart(String src, [void continuation(String s), bool minify = false]) { 50 testDart2Dart(String src, [void continuation(String s), bool minify = false,
51 bool cutDeclarationTypes = false]) {
51 // If continuation is not provided, check that source string remains the same. 52 // If continuation is not provided, check that source string remains the same.
52 if (continuation === null) { 53 if (continuation === null) {
53 continuation = (s) { Expect.equals(src, s); }; 54 continuation = (s) { Expect.equals(src, s); };
54 } 55 }
55 testDart2DartWithLibrary(src, '', continuation, minify); 56 testDart2DartWithLibrary(src, '', continuation, minify, cutDeclarationTypes);
56 } 57 }
57 58
58 /** 59 /**
59 * Library name is assumed to be 'mylib' in 'mylib.dart' file. 60 * Library name is assumed to be 'mylib' in 'mylib.dart' file.
60 */ 61 */
61 testDart2DartWithLibrary( 62 testDart2DartWithLibrary(
62 String srcMain, String srcLibrary, 63 String srcMain, String srcLibrary,
63 [void continuation(String s), bool minify = false]) { 64 [void continuation(String s), bool minify = false,
65 bool cutDeclarationTypes = false]) {
64 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path); 66 fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path);
65 67
66 final scriptUri = fileUri('script.dart'); 68 final scriptUri = fileUri('script.dart');
67 final libUri = fileUri('mylib.dart'); 69 final libUri = fileUri('mylib.dart');
68 70
69 provider(uri) { 71 provider(uri) {
70 if (uri == scriptUri) return new Future.immediate(srcMain); 72 if (uri == scriptUri) return new Future.immediate(srcMain);
71 if (uri.toString() == libUri.toString()) { 73 if (uri.toString() == libUri.toString()) {
72 return new Future.immediate(srcLibrary); 74 return new Future.immediate(srcLibrary);
73 } 75 }
74 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib); 76 if (uri.path.endsWith('/core.dart')) return new Future.immediate(coreLib);
75 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib); 77 if (uri.path.endsWith('/io.dart')) return new Future.immediate(ioLib);
76 return new Future.immediate(''); 78 return new Future.immediate('');
77 } 79 }
78 80
79 handler(uri, begin, end, message, kind) { 81 handler(uri, begin, end, message, kind) {
80 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) { 82 if (kind === Diagnostic.ERROR || kind === Diagnostic.CRASH) {
81 Expect.fail('$uri: $begin-$end: $message [$kind]'); 83 Expect.fail('$uri: $begin-$end: $message [$kind]');
82 } 84 }
83 } 85 }
84 86
85 final options = <String>['--output-type=dart']; 87 final options = <String>['--output-type=dart'];
86 if (minify) options.add('--minify'); 88 if (minify) options.add('--minify');
89 if (cutDeclarationTypes) options.add('--cutDeclarationTypes');
87 90
88 compile( 91 compile(
89 scriptUri, 92 scriptUri,
90 fileUri('libraryRoot'), 93 fileUri('libraryRoot'),
91 fileUri('packageRoot'), 94 fileUri('packageRoot'),
92 provider, 95 provider,
93 handler, 96 handler,
94 options).then(continuation); 97 options).then(continuation);
95 } 98 }
96 99
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 '''; 777 ''';
775 var expectedResult = 778 var expectedResult =
776 'interface Iterable<K>{}' 779 'interface Iterable<K>{}'
777 'interface Link<T> extends Iterable<T> default LinkFactory<T>{Link();}' 780 'interface Link<T> extends Iterable<T> default LinkFactory<T>{Link();}'
778 'class LinkFactory<T>{factory Link(){}}' 781 'class LinkFactory<T>{factory Link(){}}'
779 'main(){new Link<int>();}'; 782 'main(){new Link<int>();}';
780 testDart2DartWithLibrary(mainSrc, librarySrc, 783 testDart2DartWithLibrary(mainSrc, librarySrc,
781 (String result) { Expect.equals(expectedResult, result); }); 784 (String result) { Expect.equals(expectedResult, result); });
782 } 785 }
783 786
787 testDeclarationTypePlaceholders() {
788 var src = '''
789 String globalfield;
790 const String globalconstfield;
791
792 void foo(String arg) {}
793
794 main() {
795 String localvar;
796 foo("5");
797 }
798 ''';
799 var expectedResult =
800 ' foo( arg){}main(){var localvar; foo("5");}';
801 testDart2Dart(src,
802 (String result) { Expect.equals(expectedResult, result); },
803 cutDeclarationTypes: true);
804 }
805
784 main() { 806 main() {
785 testSignedConstants(); 807 testSignedConstants();
786 testGenericTypes(); 808 testGenericTypes();
787 testForLoop(); 809 testForLoop();
788 testEmptyList(); 810 testEmptyList();
789 testClosure(); 811 testClosure();
790 testIndexedOperatorDecl(); 812 testIndexedOperatorDecl();
791 testNativeMethods(); 813 testNativeMethods();
792 testPrefixIncrements(); 814 testPrefixIncrements();
793 testConstModifier(); 815 testConstModifier();
(...skipping 21 matching lines...) Expand all
815 testTypeVariablesAreRenamed(); 837 testTypeVariablesAreRenamed();
816 testClassTypeArgumentBound(); 838 testClassTypeArgumentBound();
817 testDoubleMains(); 839 testDoubleMains();
818 testInterfaceDefaultAnotherLib(); 840 testInterfaceDefaultAnotherLib();
819 testStaticAccessIoLib(); 841 testStaticAccessIoLib();
820 testLocalFunctionPlaceholder(); 842 testLocalFunctionPlaceholder();
821 testMinification(); 843 testMinification();
822 testClosureLocalsMinified(); 844 testClosureLocalsMinified();
823 testParametersMinified(); 845 testParametersMinified();
824 testTypeVariablesInDifferentLibraries(); 846 testTypeVariablesInDifferentLibraries();
847 testDeclarationTypePlaceholders();
825 } 848 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698