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

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

Issue 22928013: Formatter fixes and tweaks. (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
Index: pkg/analyzer_experimental/test/services/formatter_test.dart
===================================================================
--- pkg/analyzer_experimental/test/services/formatter_test.dart (revision 26430)
+++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
@@ -22,8 +22,10 @@
test('CU (1)', () {
expectCUFormatsTo(
'class A {\n'
+ ' inc(int x) => ++x;\n'
'}\n',
'class A {\n'
+ ' inc(int x) => ++x;\n'
'}\n'
);
});
@@ -93,6 +95,12 @@
'bar() {\n'
'}\n'
);
+ expectCUFormatsTo(
+ 'const A = 42;\n'
+ 'final foo = 32;\n',
+ 'const A = 42;\n'
+ 'final foo = 32;\n'
+ );
});
test('CU - imports', () {
@@ -121,7 +129,41 @@
);
});
-
+ test('CU (method body)', () {
+ expectCUFormatsTo(
+ 'class A {\n'
+ ' foo(path) {\n'
+ ' var buffer = new StringBuffer();\n'
+ ' var file = new File(path);\n'
+ ' return file;\n'
+ ' }\n'
+ '}\n',
+ 'class A {\n'
+ ' foo(path) {\n'
+ ' var buffer = new StringBuffer();\n'
+ ' var file = new File(path);\n'
+ ' return file;\n'
+ ' }\n'
+ '}\n'
+ );
+ expectCUFormatsTo(
+ 'class A {\n'
+ ' foo(files) {\n'
+ ' for (var file in files) {\n'
+ ' print(file);\n'
+ ' }\n'
+ ' }\n'
+ '}\n',
+ 'class A {\n'
+ ' foo(files) {\n'
+ ' for (var file in files) {\n'
Brian Wilkerson 2013/08/21 18:18:53 I don't think you want to produce two spaces here.
pquitslund 2013/08/21 19:40:40 Aha! That explains why the code you commented on
+ ' print(file);\n'
+ ' }\n'
+ ' }\n'
+ '}\n'
+ );
+ });
+
test('CU (method indent)', () {
expectCUFormatsTo(
'class A {\n'
@@ -132,7 +174,7 @@
' void x() {\n'
' }\n'
'}\n'
- );
+ );
});
test('CU (method indent - 2)', () {
@@ -164,7 +206,8 @@
expectCUFormatsTo(
'class A {\n'
' int x() { \n'
- 'if (true) {\nreturn 42;\n'
+ 'if (true) {\n'
+ 'return 42;\n'
'} else {\n'
'return 13;\n }\n'
' }'

Powered by Google App Engine
This is Rietveld 408576698