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

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

Issue 23121006: Minor formatter tweaks and a few more tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « pkg/analyzer_experimental/lib/src/services/formatter_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_experimental/test/services/formatter_test.dart
===================================================================
--- pkg/analyzer_experimental/test/services/formatter_test.dart (revision 26608)
+++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
@@ -67,8 +67,8 @@
'}'
);
});
-
-
+
+
// test('CU - comments', () {
// expectCUFormatsTo(
// 'library foo;\n'
@@ -83,7 +83,7 @@
// 'class C {\n}\n'
// );
// });
-
+
test('CU - top level', () {
expectCUFormatsTo(
'\n\n'
@@ -104,7 +104,7 @@
'final foo = 32;\n'
);
});
-
+
test('CU - imports', () {
expectCUFormatsTo(
'import "dart:io";\n\n'
@@ -117,7 +117,7 @@
'}\n'
);
});
-
+
test('CU - method invocations', () {
expectCUFormatsTo(
'class A {\n'
@@ -186,7 +186,7 @@
'}\n'
);
});
-
+
test('CU (method indent)', () {
expectCUFormatsTo(
'class A {\n'
@@ -276,7 +276,7 @@
'}\n'
);
});
-
+
test('CU - constructor', () {
expectCUFormatsTo(
'class A {\n'
@@ -302,7 +302,7 @@
'}\n'
);
});
-
+
test('CU - method decl w/ optional params', () {
expectCUFormatsTo(
'class A {\n'
@@ -313,7 +313,7 @@
'}\n'
);
});
-
+
test('CU - factory constructor redirects', () {
expectCUFormatsTo(
'class A {\n'
@@ -324,7 +324,7 @@
'}\n'
);
});
-
+
test('CU - constructor initializers', () {
expectCUFormatsTo(
'class A {\n'
@@ -337,7 +337,27 @@
'}\n'
);
});
-
+
+ test('CU - constructor auto field inits', () {
+ expectCUFormatsTo(
+ 'class A {\n'
+ ' int _a;\n'
+ ' A(this._a);\n'
+ '}\n',
+ 'class A {\n'
+ ' int _a;\n'
+ ' A(this._a);\n'
+ '}\n'
+ );
+ });
+
+ test('CU - parts', () {
+ expectCUFormatsTo(
+ 'part of foo;',
+ 'part of foo;'
+ );
+ });
+
test('stmt', () {
expectStmtFormatsTo(
'if (true){\n'
@@ -385,14 +405,14 @@
'}'
);
});
-
+
test('stmt (generics)', () {
expectStmtFormatsTo(
'var numbers = <int>[1, 2, (3 + 4)];',
'var numbers = <int>[1, 2, (3 + 4)];'
);
});
-
+
test('stmt (try/catch)', () {
expectStmtFormatsTo(
'try {\n'
@@ -407,7 +427,7 @@
'}'
);
});
-
+
test('stmt (binary/ternary ops)', () {
expectStmtFormatsTo(
'var a = 1 + 2 / (3 * -b);',
@@ -426,7 +446,34 @@
'var d = obj is! SomeType;'
);
});
-
+
+ test('stmt (for in)', () {
+ expectStmtFormatsTo(
+ 'for (Foo foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}',
+ 'for (Foo foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'for (final Foo foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}',
+ 'for (final Foo foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'for (final foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}',
+ 'for (final foo in bar.foos) {\n'
+ ' print(foo);\n'
+ '}'
+ );
+ });
+
test('initialIndent', () {
var formatter = new CodeFormatter(
new FormatterOptions(initialIndentationLevel: 2));
« no previous file with comments | « pkg/analyzer_experimental/lib/src/services/formatter_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698