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

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

Issue 322563002: Formatter: fix for long multiline strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
Index: pkg/analyzer/test/services/formatter_test.dart
diff --git a/pkg/analyzer/test/services/formatter_test.dart b/pkg/analyzer/test/services/formatter_test.dart
index 5ebaa88869d1ed5b737370fb4a529dda43fc47cf..c0eac776c0173f6948f42b3904abafe32b6b9b25 100644
--- a/pkg/analyzer/test/services/formatter_test.dart
+++ b/pkg/analyzer/test/services/formatter_test.dart
@@ -1000,6 +1000,51 @@ main() {
transforms: false);
});
+ test('String - multiline - short - same line', () {
+ expectCUFormatsTo(
+ 'main() {\n'
+ ' print("""01234567890123456789012345678901234567890123456789""");\n'
+ '}\n',
+ 'main() {\n'
+ ' print("""01234567890123456789012345678901234567890123456789""");\n'
+ '}\n'
+ );
+ });
+
+ test('String - multiline - short - next line', () {
+ expectCUFormatsTo(
+ 'main() {\n'
+ ' print("""\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '""");\n'
+ '}\n',
+ 'main() {\n'
+ ' print("""\n'
Brian Wilkerson 2014/06/06 17:23:54 indentation?
scheglov 2014/06/06 17:25:37 Done.
+ '01234567890123456789012345678901234567890123456789\n'
+ '""");\n'
+ '}\n'
+ );
+ });
+
+ test('String - multiline - long', () {
+ expectCUFormatsTo(
+ 'main() {\n'
+ ' print("""\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '""");\n'
+ '}\n',
+ 'main() {\n'
+ ' print("""\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '01234567890123456789012345678901234567890123456789\n'
+ '""");\n'
+ '}\n'
+ );
+ });
+
// smoketest to ensure we're enforcing the 'no gratuitous linebreaks'
// opinion
test('CU (eat newlines)', () {
@@ -1266,6 +1311,15 @@ main() {
expect(writer.toString(), equals('foo\n bar\nbaz'));
});
+ test('write - multiline', () {
+ var writer = new SourceWriter();
+ writer.indent();
+ writer.newline();
+ writer.write('aaa\nbbb\nccc');
+ expect(writer.toString(), equals('\n aaa\nbbb\nccc'));
+ expect(writer.currentLine.toString(), equals('ccc'));
+ });
+
});
« pkg/analyzer/lib/src/services/writer.dart ('K') | « pkg/analyzer/lib/src/services/writer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698