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

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

Issue 23589005: Formatter comment-handling improvements. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 27068)
+++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
@@ -76,6 +76,10 @@
'//comment two\n\n'
);
expectCUFormatsTo(
+ 'var x; //x\n',
+ 'var x; //x\n'
+ );
+ expectCUFormatsTo(
'library foo;\n'
'\n'
'//comment one\n'
@@ -329,7 +333,8 @@
'}\n',
'/** Old school class comment */\n'
'class C {\n'
- ' /** Foo! */ int foo() => 42;\n'
+ ' /** Foo! */\n'
+ ' int foo() => 42;\n'
'}\n'
);
expectCUFormatsTo(
@@ -406,7 +411,131 @@
);
});
+ test('CU - mixed comments', () {
+ expectCUFormatsTo(
+ 'library foo;\n'
+ '\n'
+ '\n'
+ '/* Comment 1 */\n'
+ '\n'
+ '// Comment 2\n'
+ '\n'
+ '/* Comment 3 */',
+ 'library foo;\n'
+ '\n'
+ '\n'
+ '/* Comment 1 */\n'
+ '\n'
+ '// Comment 2\n'
+ '\n'
+ '/* Comment 3 */'
+ );
+ });
+ test('CU - comments (EOF)', () {
+ expectCUFormatsTo(
+ 'library foo; //zamm',
+ 'library foo; //zamm\n' //<-- note extra NEWLINE
+ );
+ });
+
+ test('CU - comments (0)', () {
+ expectCUFormatsTo(
+ 'library foo; //zamm\n'
+ '\n'
+ 'class A {\n'
+ '}\n',
+ 'library foo; //zamm\n'
+ '\n'
+ 'class A {\n'
+ '}\n'
+ );
+ });
+
+ test('CU - comments (1)', () {
+ expectCUFormatsTo(
+ '/* foo */ /* bar */\n',
+ '/* foo */ /* bar */\n'
+ );
+ });
+
+ test('CU - comments (2)', () {
+ expectCUFormatsTo(
+ '/** foo */ /** bar */\n',
+ '/** foo */\n'
+ '/** bar */\n'
+ );
+ });
+
+ test('CU - comments (3)', () {
+ expectCUFormatsTo(
+ 'var x; //x\n',
+ 'var x; //x\n'
+ );
+ });
+
+ test('CU - comments (4)', () {
+ expectCUFormatsTo(
+ 'class X { //X!\n'
+ '}',
+ 'class X { //X!\n'
+ '}'
+ );
+ });
+
+ test('CU - comments (5)', () {
+ expectCUFormatsTo(
+ '//comment one\n\n'
+ '//comment two\n\n',
+ '//comment one\n\n'
+ '//comment two\n\n'
+ );
+ });
+
+ test('CU - comments (6)', () {
+ expectCUFormatsTo(
+ 'var x; //x\n',
+ 'var x; //x\n'
+ );
+ });
+
+ test('CU - comments (6)', () {
+ expectCUFormatsTo(
+ 'var /* int */ x; //x\n',
+ 'var /* int */ x; //x\n'
+ );
+ });
+
+ test('CU - comments (7)', () {
+ expectCUFormatsTo(
+ 'library foo;\n'
+ '\n'
+ '/// Docs\n'
+ '/// spanning\n'
+ '/// lines.\n'
+ 'class A {\n'
+ '}\n'
+ '\n'
+ '/// ... and\n'
+ '\n'
+ '/// Dangling ones too\n'
+ 'int x;\n',
+ 'library foo;\n'
+ '\n'
+ '/// Docs\n'
+ '/// spanning\n'
+ '/// lines.\n'
+ 'class A {\n'
+ '}\n'
+ '\n'
+ '/// ... and\n'
+ '\n'
+ '/// Dangling ones too\n'
+ 'int x;\n'
+ );
+ });
+
+
test('CU - constructor', () {
expectCUFormatsTo(
'class A {\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