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

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

Issue 25350003: Flow control structure formatting (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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 ); 756 );
757 expectStmtFormatsTo( 757 expectStmtFormatsTo(
758 'for (final foo in bar.foos) {\n' 758 'for (final foo in bar.foos) {\n'
759 ' print(foo);\n' 759 ' print(foo);\n'
760 '}', 760 '}',
761 'for (final foo in bar.foos) {\n' 761 'for (final foo in bar.foos) {\n'
762 ' print(foo);\n' 762 ' print(foo);\n'
763 '}' 763 '}'
764 ); 764 );
765 }); 765 });
766
767 test('Statement (if)', () {
768 expectStmtFormatsTo('if (true) print("true!");',
769 'if (true) print("true!");');
770 expectStmtFormatsTo('if (true) { print("true!"); }',
771 'if (true) {\n'
772 ' print("true!");\n'
773 '}');
774 expectStmtFormatsTo('if (true) print("true!"); else print("false!");',
775 'if (true) {\n'
776 ' print("true!");\n'
777 '} else {\n'
778 ' print("false!");\n'
779 '}');
780 });
766 781
767 test('initialIndent', () { 782 test('initialIndent', () {
768 var formatter = new CodeFormatter( 783 var formatter = new CodeFormatter(
769 new FormatterOptions(initialIndentationLevel: 2)); 784 new FormatterOptions(initialIndentationLevel: 2));
770 var formattedSource = 785 var formattedSource =
771 formatter.format(CodeKind.STATEMENT, 'var x;').source; 786 formatter.format(CodeKind.STATEMENT, 'var x;').source;
772 expect(formattedSource, startsWith(' ')); 787 expect(formattedSource, startsWith(' '));
773 }); 788 });
774 789
775 test('selections', () { 790 test('selections', () {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 1008
994 expectStreamsNotEqual(Token t1, Token t2) => 1009 expectStreamsNotEqual(Token t1, Token t2) =>
995 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), 1010 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(),
996 throwsA(new isInstanceOf<FormatterException>())); 1011 throwsA(new isInstanceOf<FormatterException>()));
997 1012
998 expectCUFormatsTo(src, expected) => 1013 expectCUFormatsTo(src, expected) =>
999 expect(formatCU(src).source, equals(expected)); 1014 expect(formatCU(src).source, equals(expected));
1000 1015
1001 expectStmtFormatsTo(src, expected) => 1016 expectStmtFormatsTo(src, expected) =>
1002 expect(formatStatement(src), equals(expected)); 1017 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