Chromium Code Reviews| 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' |
| ' }' |