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

Unified Diff: pkg/analyzer/test/services/formatter_test.dart

Issue 189063006: add indent option to cmdline formatter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
« pkg/analyzer/bin/formatter.dart ('K') | « pkg/analyzer/bin/formatter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/services/formatter_test.dart
diff --git a/pkg/analyzer/test/services/formatter_test.dart b/pkg/analyzer/test/services/formatter_test.dart
index c77f6f9ae3c4a252c1678fd1fcd0483c8e51f792..25e24875227c3843b9f16585438ce92fe22ff473 100644
--- a/pkg/analyzer/test/services/formatter_test.dart
+++ b/pkg/analyzer/test/services/formatter_test.dart
@@ -49,6 +49,47 @@ main() {
throwsA(new isInstanceOf<FormatterException>()));
});
+ test('indent', () {
+ var original =
+ 'class A {\n'
+ ' var z;\n'
+ ' inc(int x) => ++x;\n'
+ ' foo(int x) {\n'
+ ' if (x == 0) {\n'
+ ' return true;\n'
+ ' }\n'
+ ' }\n'
+ '}\n';
+ expectCUFormatsTo(
+ original,
+ original
+ );
+// expectIndentFormatsTo(3, false,
+// original,
+// 'class A {\n'
+// ' var z;\n'
+// ' inc(int x) => ++x;\n'
+// ' foo(int x) {\n'
+// ' if (x == 0) {\n'
+// ' return true;\n'
+// ' }\n'
+// ' }\n'
+// '}\n'
+// );
+// expectIndentFormatsTo(1, true,
+// original,
+// 'class A {\n'
+// '\tvar z;\n'
+// '\tinc(int x) => ++x;\n'
+// '\tfoo(int x) {\n'
+// '\t\tif (x == 0) {\n'
+// '\t\t\treturn true;\n'
+// '\t\t}\n'
+// '\t}\n'
+// '}\n'
+// );
+ });
+
test('CU (1)', () {
expectCUFormatsTo(
'class A {\n'
@@ -1417,6 +1458,14 @@ expectCUFormatsTo(src, expected, {transforms: true}) =>
expect(formatCU(src, options: new FormatterOptions(
codeTransforms: transforms)).source, equals(expected));
+expectIndentFormatsTo(spacesPerIndent, tabsForIndent, src, expected) =>
+ expect(
+ formatCU(src, options: new FormatterOptions(
+ spacesPerIndent: spacesPerIndent,
+ tabsForIndent: tabsForIndent
+ )).source,
+ equals(expected));
+
expectStmtFormatsTo(src, expected, {transforms: true}) =>
expect(formatStatement(src, options:
new FormatterOptions(codeTransforms: transforms)), equals(expected));
« pkg/analyzer/bin/formatter.dart ('K') | « pkg/analyzer/bin/formatter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698