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

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

Issue 109423004: Formatter line continuation awareness hooks. (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 31147)
+++ pkg/analyzer/test/services/formatter_test.dart (working copy)
@@ -914,6 +914,101 @@
transforms: false);
});
+ test('line continuations - 1', () {
+ expectStmtFormatsTo(
+ 'if (x &&\n'
+ ' y) {\n'
+ ' print("yes!");\n'
+ '}',
+ 'if (x &&\n'
+ ' y) {\n'
+ ' print("yes!");\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'var x =\n'
+ ' 1234567890;',
+ 'var x =\n'
+ ' 1234567890;'
+ );
+ expectStmtFormatsTo(
+ 'foo() {\n'
+ ' var x = 0;\n'
+ ' x =\n'
+ ' 1234567890;\n'
+ '}',
+ 'foo() {\n'
+ ' var x = 0;\n'
+ ' x =\n'
+ ' 1234567890;\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'foo() {\n'
+ ' while (true &&\n'
+ ' true) {\n'
+ ' print("!");\n'
+ ' }\n'
+ '}',
+ 'foo() {\n'
+ ' while (true &&\n'
+ ' true) {\n'
+ ' print("!");\n'
+ ' }\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'foo() {\n'
+ ' do {\n'
+ ' print("!");\n'
+ ' } while (true &&\n'
+ ' true);\n'
+ '}',
+ 'foo() {\n'
+ ' do {\n'
+ ' print("!");\n'
+ ' } while (true &&\n'
+ ' true);\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'int foo() {\n'
+ ' return\n'
+ ' foo();\n'
+ '}',
+ 'int foo() {\n'
+ ' return\n'
+ ' foo();\n'
+ '}'
+ );
+ expectStmtFormatsTo(
+ 'true ? foo() :\n'
+ ' bar();',
+ 'true ? foo() :\n'
+ ' bar();'
+ );
+ expectCUFormatsTo(
+ 'import "dart:core" as\n'
+ ' core;\n',
+ 'import "dart:core" as\n'
+ ' core;\n'
+ );
+ expectCUFormatsTo(
+ 'export "package:foo/foo.dart" show\n'
+ ' Foo;\n',
+ 'export "package:foo/foo.dart" show\n'
+ ' Foo;\n'
+ );
+ expectCUFormatsTo(
+ 'class Foo extends Bar implements\n'
+ ' Baz {\n'
+ '}\n',
+ 'class Foo extends Bar implements\n'
+ ' Baz {\n'
+ '}\n'
+ );
+ });
+
test('initialIndent', () {
var formatter = new CodeFormatter(
new FormatterOptions(initialIndentationLevel: 2));

Powered by Google App Engine
This is Rietveld 408576698