Chromium Code Reviews| Index: pkg/analyzer_experimental/test/services/formatter_test.dart |
| =================================================================== |
| --- pkg/analyzer_experimental/test/services/formatter_test.dart (revision 26740) |
| +++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy) |
| @@ -68,21 +68,59 @@ |
| ); |
| }); |
| + test('CU - EOL comments', () { |
| + expectCUFormatsTo( |
| + '//comment one\n\n' |
| + '//comment two\n\n', |
| + '//comment one\n\n' |
| + '//comment two\n\n' |
| + ); |
| + expectCUFormatsTo( |
| + 'library foo;\n' |
| + '\n' |
| + '//comment one\n' |
| + '\n' |
| + 'class C {\n' |
| + '}\n', |
| + 'library foo;\n' |
| + '\n' |
| + '//comment one\n' |
| + '\n' |
| + 'class C {\n' |
| + '}\n' |
| + ); |
| + expectCUFormatsTo( |
| + 'library foo;\n' |
| + '\n' |
| + '//comment one\n' |
| + '\n' |
| + '//comment two\n' |
| + '\n' |
| + 'class C {\n' |
| + '}\n', |
| + 'library foo;\n' |
| + '\n' |
| + '//comment one\n' |
| + '\n' |
| + '//comment two\n' |
| + '\n' |
| + 'class C {\n' |
| + '}\n' |
| + ); |
| + }); |
| -// test('CU - comments', () { |
| -// expectCUFormatsTo( |
| -// 'library foo;\n' |
| -// '\n' |
| -// '//comment one\n\n' |
| -// '//comment two\n\n' |
| -// 'class C {\n}\n', |
| -// 'library foo;\n' |
| -// '\n' |
| -// '//comment one\n\n' |
| -// '//comment two\n\n' |
| -// 'class C {\n}\n' |
| -// ); |
| -// }); |
| + test('CU - nested functions', () { |
| + expectCUFormatsTo( |
| + 'x() {\n' |
| + ' y() {\n' |
| + ' }\n' |
| + '}\n', |
| + 'x() {\n' |
| + ' y() {\n' |
| + ' }\n' |
| + '}\n' |
| + ); |
| + }); |
| test('CU - top level', () { |
| expectCUFormatsTo( |
| @@ -116,6 +154,12 @@ |
| 'foo() {\n' |
| '}\n' |
| ); |
| + expectCUFormatsTo( |
| + 'library a; class B { }', |
| + 'library a;\n' |
| + 'class B {\n' |
| + '}' |
| + ); |
| }); |
| test('CU - method invocations', () { |
| @@ -277,6 +321,92 @@ |
| ); |
| }); |
| + test('CU - Block comments', () { |
| + expectCUFormatsTo( |
| + '/** Old school class comment */\n' |
| + 'class C {\n' |
| + ' /** Foo! */ int foo() => 42;\n' |
| + '}\n', |
| + '/** Old school class comment */\n' |
| + 'class C {\n' |
| + ' /** Foo! */ int foo() => 42;\n' |
| + '}\n' |
| + ); |
| + expectCUFormatsTo( |
| + 'library foo;\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n', |
| + 'library foo;\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n' |
| + ); |
| + expectCUFormatsTo( |
| + 'library foo;\n' |
| + '/* A long\n' |
| + ' * Comment\n' |
| + '*/\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n', |
| + 'library foo;\n' |
| + '/* A long\n' |
| + ' * Comment\n' |
| + '*/\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n' |
| + ); |
| + expectCUFormatsTo( |
|
Brian Wilkerson
2013/08/27 21:12:45
Related to my earlier questions, what happens if t
pquitslund
2013/08/27 21:55:38
Predictably this breaks. Thanks for the catch. S
|
| + 'library foo;\n' |
| + '/* A long\n' |
| + ' * Comment\n' |
| + '*/\n' |
| + '\n' |
| + '/* And\n' |
| + ' * another...\n' |
| + '*/\n' |
| + '\n' |
| + '// Mixing it up\n' |
| + '\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n', |
| + 'library foo;\n' |
| + '/* A long\n' |
| + ' * Comment\n' |
| + '*/\n' |
| + '\n' |
| + '/* And\n' |
| + ' * another...\n' |
| + '*/\n' |
| + '\n' |
| + '// Mixing it up\n' |
| + '\n' |
| + 'class C /* is cool */ {\n' |
| + ' /* int */ foo() => 42;\n' |
| + '}\n' |
| + ); |
| + expectCUFormatsTo( |
| + '/// Copyright info\n' |
| + '\n' |
| + 'library foo;\n' |
| + '/// Class comment\n' |
| + '//TODO: implement\n' |
| + 'class C {\n' |
| + '}\n', |
| + '/// Copyright info\n' |
| + '\n' |
| + 'library foo;\n' |
| + '/// Class comment\n' |
| + '//TODO: implement\n' |
| + 'class C {\n' |
| + '}\n' |
| + ); |
| + }); |
| + |
| + |
| test('CU - constructor', () { |
| expectCUFormatsTo( |
| 'class A {\n' |
| @@ -354,7 +484,7 @@ |
| test('CU - parts', () { |
| expectCUFormatsTo( |
| 'part of foo;', |
| - 'part of foo;' |
| + 'part of foo;\n' |
| ); |
| }); |
| @@ -413,6 +543,13 @@ |
| ); |
| }); |
| + test('stmt (maps)', () { |
| + expectStmtFormatsTo( |
| + 'var map = const {"foo": "bar", "fuz": null};', |
| + 'var map = const {"foo": "bar", "fuz": null};' |
| + ); |
| + }); |
| + |
| test('stmt (try/catch)', () { |
| expectStmtFormatsTo( |
| 'try {\n' |