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

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

Issue 105613003: Fix for map and list literal indentation (dartbug.com/15453). (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/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/src/generated/java_core.dart' show CharSequence; 7 import 'package:analyzer/src/generated/java_core.dart' show CharSequence;
8 import 'package:analyzer/src/generated/scanner.dart'; 8 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/services/formatter_impl.dart'; 9 import 'package:analyzer/src/services/formatter_impl.dart';
10 import 'package:analyzer/src/services/writer.dart'; 10 import 'package:analyzer/src/services/writer.dart';
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 'var numbers = <int>[1, 2, (3 + 4)];', 775 'var numbers = <int>[1, 2, (3 + 4)];',
776 'var numbers = <int>[1, 2, (3 + 4)];' 776 'var numbers = <int>[1, 2, (3 + 4)];'
777 ); 777 );
778 }); 778 });
779 779
780 test('stmt (lists)', () { 780 test('stmt (lists)', () {
781 expectStmtFormatsTo( 781 expectStmtFormatsTo(
782 'var l = [1,2,3,4];', 782 'var l = [1,2,3,4];',
783 'var l = [1, 2, 3, 4];' 783 'var l = [1, 2, 3, 4];'
784 ); 784 );
785 expectStmtFormatsTo(
786 'var l = [\n'
787 '1,\n'
788 '2,\n'
789 '];',
790 'var l = [\n'
791 ' 1,\n'
792 ' 2,\n'
793 '];'
794 );
785 //Dangling ',' 795 //Dangling ','
786 expectStmtFormatsTo( 796 expectStmtFormatsTo(
787 'var l = [1,];', 797 'var l = [1,];',
788 'var l = [1,];' 798 'var l = [1,];'
789 ); 799 );
790 }); 800 });
791 801
792 test('stmt (maps)', () { 802 test('stmt (maps)', () {
793 expectStmtFormatsTo( 803 expectStmtFormatsTo(
794 'var map = const {"foo": "bar", "fuz": null};', 804 'var map = const {"foo": "bar", "fuz": null};',
795 'var map = const {"foo": "bar", "fuz": null};' 805 'var map = const {"foo": "bar", "fuz": null};'
796 ); 806 );
797 807
808 expectStmtFormatsTo(
809 'var map = {\n'
810 '"foo": "bar",\n'
811 '"bar": "baz"'
812 '};',
813 'var map = {\n'
814 ' "foo": "bar",\n'
815 ' "bar": "baz"'
816 '};'
817 );
818
798 //Dangling ',' 819 //Dangling ','
799 expectStmtFormatsTo( 820 expectStmtFormatsTo(
800 'var map = {"foo": "bar",};', 821 'var map = {"foo": "bar",};',
801 'var map = {"foo": "bar",};' 822 'var map = {"foo": "bar",};'
802 ); 823 );
803 }); 824 });
804 825
805 test('stmt (try/catch)', () { 826 test('stmt (try/catch)', () {
806 expectStmtFormatsTo( 827 expectStmtFormatsTo(
807 'try {\n' 828 'try {\n'
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), 1136 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(),
1116 throwsA(new isInstanceOf<FormatterException>())); 1137 throwsA(new isInstanceOf<FormatterException>()));
1117 1138
1118 expectCUFormatsTo(src, expected, {transforms: true}) => 1139 expectCUFormatsTo(src, expected, {transforms: true}) =>
1119 expect(formatCU(src, options: new FormatterOptions( 1140 expect(formatCU(src, options: new FormatterOptions(
1120 codeTransforms: transforms)).source, equals(expected)); 1141 codeTransforms: transforms)).source, equals(expected));
1121 1142
1122 expectStmtFormatsTo(src, expected, {transforms: true}) => 1143 expectStmtFormatsTo(src, expected, {transforms: true}) =>
1123 expect(formatStatement(src, options: 1144 expect(formatStatement(src, options:
1124 new FormatterOptions(codeTransforms: transforms)), equals(expected)); 1145 new FormatterOptions(codeTransforms: transforms)), equals(expected));
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/services/formatter_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698