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

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

Issue 113693003: dartfmt gets opinionated about 'gratuitous' linebreaks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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
Index: pkg/analyzer/test/services/formatter_test.dart
===================================================================
--- pkg/analyzer/test/services/formatter_test.dart (revision 31210)
+++ pkg/analyzer/test/services/formatter_test.dart (working copy)
@@ -566,7 +566,10 @@
test('CU - comments (11)', () {
expectCUFormatsTo(
'var m = {1: 2 /* bang */, 3: 4};\n',
- 'var m = {1: 2 /* bang */, 3: 4};\n'
+ 'var m = {\n'
+ ' 1: 2 /* bang */,\n'
+ ' 3: 4\n'
+ '};\n'
);
});
@@ -787,10 +790,7 @@
'1,\n'
'2,\n'
'];',
- 'var l = [\n'
- ' 1,\n'
- ' 2,\n'
- '];'
+ 'var l = [1, 2,];'
);
//Dangling ','
expectStmtFormatsTo(
@@ -802,24 +802,29 @@
test('stmt (maps)', () {
expectStmtFormatsTo(
'var map = const {"foo": "bar", "fuz": null};',
- 'var map = const {"foo": "bar", "fuz": null};'
+ 'var map = const {\n'
+ ' "foo": "bar",\n'
+ ' "fuz": null\n'
+ '};'
);
expectStmtFormatsTo(
'var map = {\n'
'"foo": "bar",\n'
- '"bar": "baz"'
+ '"bar": "baz"\n'
'};',
'var map = {\n'
' "foo": "bar",\n'
- ' "bar": "baz"'
+ ' "bar": "baz"\n'
'};'
);
//Dangling ','
expectStmtFormatsTo(
'var map = {"foo": "bar",};',
- 'var map = {"foo": "bar",};'
+ 'var map = {\n'
+ ' "foo": "bar",\n'
+ '};'
);
});
@@ -914,6 +919,18 @@
transforms: false);
});
+ // smoketest to ensure we're enforcing the 'no gratuitous linebreaks'
+ // opinion
+ test('CU (eat newlines)', () {
+ expectCUFormatsTo(
+ 'abstract\n'
+ 'class\n'
+ 'A{}',
+ 'abstract class A {\n'
+ '}\n'
+ );
+ });
+
// test('line continuations - 1', () {
// expectStmtFormatsTo(
// 'if (x &&\n'

Powered by Google App Engine
This is Rietveld 408576698