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

Side by Side Diff: pkg/analyzer_experimental/test/services/formatter_test.dart

Issue 25609002: Formatting constructor initializers a la the Style Guide. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer_experimental/lib/src/services/formatter_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
6 6
7 import 'package:analyzer_experimental/src/generated/scanner.dart'; 7 import 'package:analyzer_experimental/src/generated/scanner.dart';
8 import 'package:analyzer_experimental/src/services/formatter_impl.dart'; 8 import 'package:analyzer_experimental/src/services/formatter_impl.dart';
9 import 'package:analyzer_experimental/src/services/writer.dart'; 9 import 'package:analyzer_experimental/src/services/writer.dart';
10 10
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 }); 591 });
592 592
593 test('CU - constructor initializers', () { 593 test('CU - constructor initializers', () {
594 expectCUFormatsTo( 594 expectCUFormatsTo(
595 'class A {\n' 595 'class A {\n'
596 ' int _a;\n' 596 ' int _a;\n'
597 ' A(a) : _a = a;\n' 597 ' A(a) : _a = a;\n'
598 '}\n', 598 '}\n',
599 'class A {\n' 599 'class A {\n'
600 ' int _a;\n' 600 ' int _a;\n'
601 ' A(a) : _a = a;\n' 601 ' A(a)\n'
602 ' : _a = a;\n'
602 '}\n' 603 '}\n'
603 ); 604 );
604 }); 605 });
605 606
606 test('CU - constructor auto field inits', () { 607 test('CU - constructor auto field inits', () {
607 expectCUFormatsTo( 608 expectCUFormatsTo(
608 'class A {\n' 609 'class A {\n'
609 ' int _a;\n' 610 ' int _a;\n'
610 ' A(this._a);\n' 611 ' A(this._a);\n'
611 '}\n', 612 '}\n',
612 'class A {\n' 613 'class A {\n'
613 ' int _a;\n' 614 ' int _a;\n'
614 ' A(this._a);\n' 615 ' A(this._a);\n'
615 '}\n' 616 '}\n'
616 ); 617 );
617 }); 618 });
618 619
619 test('CU - parts', () { 620 test('CU - parts', () {
620 expectCUFormatsTo( 621 expectCUFormatsTo(
621 'part of foo;', 622 'part of foo;',
622 'part of foo;\n' 623 'part of foo;\n'
623 ); 624 );
624 }); 625 });
626
627 test('CU (cons inits)', () {
628 expectCUFormatsTo('class X {\n'
629 ' var x, y;\n'
630 ' X() : x = 1, y = 2;\n'
631 '}\n',
632 'class X {\n'
633 ' var x, y;\n'
634 ' X()\n'
635 ' : x = 1,\n'
636 ' y = 2;\n'
637 '}\n'
638 );
639 });
625 640
626 test('stmt', () { 641 test('stmt', () {
627 expectStmtFormatsTo( 642 expectStmtFormatsTo(
628 'if (true){\n' 643 'if (true){\n'
629 'if (true){\n' 644 'if (true){\n'
630 'if (true){\n' 645 'if (true){\n'
631 'return true;\n' 646 'return true;\n'
632 '} else{\n' 647 '} else{\n'
633 'return false;\n' 648 'return false;\n'
634 '}\n' 649 '}\n'
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1023
1009 expectStreamsNotEqual(Token t1, Token t2) => 1024 expectStreamsNotEqual(Token t1, Token t2) =>
1010 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), 1025 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(),
1011 throwsA(new isInstanceOf<FormatterException>())); 1026 throwsA(new isInstanceOf<FormatterException>()));
1012 1027
1013 expectCUFormatsTo(src, expected) => 1028 expectCUFormatsTo(src, expected) =>
1014 expect(formatCU(src).source, equals(expected)); 1029 expect(formatCU(src).source, equals(expected));
1015 1030
1016 expectStmtFormatsTo(src, expected) => 1031 expectStmtFormatsTo(src, expected) =>
1017 expect(formatStatement(src), equals(expected)); 1032 expect(formatStatement(src), equals(expected));
OLDNEW
« 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