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

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

Issue 23308004: Formatter checkpoint. (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 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'
+ '}'
);
});
« 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