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

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

Issue 477373002: Improve formatting of variable declarations/assignments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/test/services/data/wrap_tests.data ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c4907ac1d2c96d8f3598bb4aee3d3b76bc8839ac..5416b24b6d486b80d4828191772649452b48c166 100644
--- a/pkg/analyzer/test/services/formatter_test.dart
+++ b/pkg/analyzer/test/services/formatter_test.dart
@@ -1362,6 +1362,7 @@ main() {
final SP_1 = new SpaceToken(1, breakWeight: DEFAULT_SPACE_WEIGHT);
final SP_w1 = new SpaceToken(1, breakWeight: 1);
final SP_w2 = new SpaceToken(1, breakWeight: 2);
+ final SP_i = new SpaceToken(1, breakWeight: SINGLE_SPACE_WEIGHT);
// 'foo|1|bar|1|baz|1|foo|1|bar|1|baz'
final LINE_1 = line(['foo', SP_1, 'bar', SP_1, 'baz', SP_1,
@@ -1437,6 +1438,31 @@ main() {
expect(result, '111111 222222\n 333333 444444\n 555555 666666');
});
+ test('printLine - use weight - initializer - success', () {
+ var source = line(
+ ['111111', SP_i, '2222', SP_w1,
+ '3333', SP_w1, '4444']);
+ var result = printLine(source, 20);
+ expect(result, '111111\n 2222 3333 4444');
+ });
+
+ test('printLine - use weight - initializer - rest too long', () {
+ var source = line(
+ ['111', SP_i, '222', SP_w1,
+ '333', SP_w1, '444', SP_w1, '555', SP_w1, '666']);
+ var result = printLine(source, 15);
+ expect(result, '111 222\n 333\n 444\n 555\n 666');
+ });
+
+ test('printLine - use weight - initializer - decl/rest too long', () {
+ var source = line(
+ ['111', SP_i, '2222222222222', SP_w1,
+ '333', SP_w1, '444', SP_w1, '555', SP_w1, '666']);
+ var result = printLine(source, 15);
+ expect(result, '111\n 2222222222222\n'
+ ' 333\n 444\n 555\n 666');
+ });
+
test('isWhitespace', () {
expect(isWhitespace('foo'), false);
expect(isWhitespace(' foo'), false);
@@ -1579,8 +1605,7 @@ expectStmtFormatsTo(src, expected, {transforms: true}) =>
new FormatterOptions(codeTransforms: transforms)), equals(expected));
-runTests(testFileName, expectClause(input, output)) {
-
+runTests(testFileName, expectClause(String input, String output)) {
var testIndex = 1;
var testFile = new File(join(TEST_DATA_DIR, testFileName));
var lines = testFile.readAsLinesSync();
« no previous file with comments | « pkg/analyzer/test/services/data/wrap_tests.data ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698