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

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

Issue 10875040: Support customizing API (and hence mock) compiler to minify the output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/unparser_test.dart
diff --git a/tests/compiler/dart2js/unparser_test.dart b/tests/compiler/dart2js/unparser_test.dart
index bcac52673cf058ec35dc4a32761bf4eca91acac9..3a8c2f8eb8d8b459d89846e4cc1209ccb10ce387 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -47,19 +47,20 @@ class Platform {
}
''';
-testDart2Dart(String src, [void continuation(String s)]) {
+testDart2Dart(String src, [void continuation(String s), bool minify = false]) {
// If continuation is not provided, check that source string remains the same.
if (continuation === null) {
continuation = (s) { Expect.equals(src, s); };
}
- testDart2DartWithLibrary(src, '', continuation);
+ testDart2DartWithLibrary(src, '', continuation, minify);
}
/**
* Library name is assumed to be 'mylib' in 'mylib.dart' file.
*/
testDart2DartWithLibrary(
- String srcMain, String srcLibrary, [void continuation(String s)]) {
+ String srcMain, String srcLibrary,
+ [void continuation(String s), bool minify = false]) {
fileUri(path) => new Uri.fromComponents(scheme: 'file', path: path);
final scriptUri = fileUri('script.dart');
@@ -81,13 +82,16 @@ testDart2DartWithLibrary(
}
}
+ final options = <String>['--output-type=dart'];
+ if (minify) options.add('--minify');
+
compile(
scriptUri,
fileUri('libraryRoot'),
fileUri('packageRoot'),
provider,
handler,
- const ['--output-type=dart']).then(continuation);
+ options).then(continuation);
}
testSignedConstants() {
@@ -674,6 +678,20 @@ main() {
(String result) { Expect.equals(expectedResult, result); });
}
+testMinification() {
+ var src = '''
+class ClassWithVeryVeryLongName {}
+main() {
+ new ClassWithVeryVeryLongName();
+}
+''';
+ var expectedResult =
+ 'class A{}'
+ 'main(){new A();}';
+ testDart2Dart(src,
+ (String result) { Expect.equals(expectedResult, result); }, minify: true);
+}
+
main() {
testSignedConstants();
testGenericTypes();
@@ -711,4 +729,5 @@ main() {
testInterfaceDefaultAnotherLib();
testStaticAccessIoLib();
testLocalFunctionPlaceholder();
+ testMinification();
}
« 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