| Index: pkg/analyzer_experimental/test/services/formatter_test.dart
|
| ===================================================================
|
| --- pkg/analyzer_experimental/test/services/formatter_test.dart (revision 26324)
|
| +++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
|
| @@ -22,7 +22,7 @@
|
| test('CU (1)', () {
|
| expectCUFormatsTo(
|
| 'class A {\n'
|
| - '}',
|
| + '}\n',
|
| 'class A {\n'
|
| '}\n'
|
| );
|
| @@ -31,7 +31,7 @@
|
| test('CU (2)', () {
|
| expectCUFormatsTo(
|
| 'class A { \n'
|
| - '}',
|
| + '}\n',
|
| 'class A {\n'
|
| '}\n'
|
| );
|
| @@ -42,19 +42,72 @@
|
| 'class A {\n'
|
| ' }',
|
| 'class A {\n'
|
| - '}\n'
|
| + '}'
|
| );
|
| });
|
|
|
| test('CU (4)', () {
|
| expectCUFormatsTo(
|
| ' class A {\n'
|
| - '}',
|
| + '}\n',
|
| 'class A {\n'
|
| '}\n'
|
| );
|
| });
|
|
|
| + test('CU (5)', () {
|
| + expectCUFormatsTo(
|
| + 'class A { int meaningOfLife() => 42; }',
|
| + 'class A {\n'
|
| + ' int meaningOfLife() => 42;\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 - top level', () {
|
| + expectCUFormatsTo(
|
| + '\n\n'
|
| + 'foo() {\n'
|
| + '}\n'
|
| + 'bar() {\n'
|
| + '}\n',
|
| + '\n\n'
|
| + 'foo() {\n'
|
| + '}\n'
|
| + 'bar() {\n'
|
| + '}\n'
|
| + );
|
| + });
|
| +
|
| + test('CU - imports', () {
|
| + expectCUFormatsTo(
|
| + 'import "dart:io";\n\n'
|
| + 'import "package:unittest/unittest.dart";\n'
|
| + 'foo() {\n'
|
| + '}\n',
|
| + 'import "dart:io";\n\n'
|
| + 'import "package:unittest/unittest.dart";\n'
|
| + 'foo() {\n'
|
| + '}\n'
|
| + );
|
| + });
|
| +
|
| test('CU w/class decl comment', () {
|
| expectCUFormatsTo(
|
| 'import "foo";\n\n'
|
| @@ -64,7 +117,7 @@
|
| 'import "foo";\n\n'
|
| '//Killer class\n'
|
| 'class A {\n'
|
| - '}\n'
|
| + '}'
|
| );
|
| });
|
|
|
| @@ -74,7 +127,7 @@
|
| 'class A {\n'
|
| 'void x(){\n'
|
| '}\n'
|
| - '}',
|
| + '}\n',
|
| 'class A {\n'
|
| ' void x() {\n'
|
| ' }\n'
|
| @@ -85,8 +138,9 @@
|
| test('CU (method indent - 2)', () {
|
| expectCUFormatsTo(
|
| 'class A {\n'
|
| - ' static bool x(){ return true; }\n'
|
| - ' }',
|
| + ' static bool x(){\n'
|
| + 'return true; }\n'
|
| + ' }\n',
|
| 'class A {\n'
|
| ' static bool x() {\n'
|
| ' return true;\n'
|
| @@ -99,7 +153,7 @@
|
| expectCUFormatsTo(
|
| 'class A {\n'
|
| ' int x() => 42 + 3 ; \n'
|
| - ' }',
|
| + ' }\n',
|
| 'class A {\n'
|
| ' int x() => 42 + 3;\n'
|
| '}\n'
|
| @@ -110,10 +164,11 @@
|
| expectCUFormatsTo(
|
| 'class A {\n'
|
| ' int x() { \n'
|
| - 'if (true) {return 42;\n'
|
| - '} else { return 13; }\n'
|
| + 'if (true) {\nreturn 42;\n'
|
| + '} else {\n'
|
| + 'return 13;\n }\n'
|
| ' }'
|
| - '}',
|
| + '}\n',
|
| 'class A {\n'
|
| ' int x() {\n'
|
| ' if (true) {\n'
|
| @@ -192,7 +247,7 @@
|
| 'case "fig":\n'
|
| 'print("bleh");\n'
|
| 'break;\n'
|
| - '}\n',
|
| + '}',
|
| 'switch (fruit) {\n'
|
| ' case "apple":\n'
|
| ' print("delish");\n'
|
| @@ -200,7 +255,7 @@
|
| ' case "fig":\n'
|
| ' print("bleh");\n'
|
| ' break;\n'
|
| - '}\n'
|
| + '}'
|
| );
|
| });
|
|
|
| @@ -217,12 +272,12 @@
|
| 'doSomething();\n'
|
| '} catch (e) {\n'
|
| 'print(e);\n'
|
| - '}\n',
|
| + '}',
|
| 'try {\n'
|
| ' doSomething();\n'
|
| '} catch (e) {\n'
|
| ' print(e);\n'
|
| - '}\n'
|
| + '}'
|
| );
|
| });
|
|
|
|
|