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

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

Issue 23451037: Optional trailing comma support for list and map literals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 '}' 664 '}'
665 ); 665 );
666 }); 666 });
667 667
668 test('stmt (generics)', () { 668 test('stmt (generics)', () {
669 expectStmtFormatsTo( 669 expectStmtFormatsTo(
670 'var numbers = <int>[1, 2, (3 + 4)];', 670 'var numbers = <int>[1, 2, (3 + 4)];',
671 'var numbers = <int>[1, 2, (3 + 4)];' 671 'var numbers = <int>[1, 2, (3 + 4)];'
672 ); 672 );
673 }); 673 });
674
675 test('stmt (lists)', () {
676 expectStmtFormatsTo(
677 'var l = [1,2,3,4];',
678 'var l = [1, 2, 3, 4];'
679 );
680 //Dangling ','
681 expectStmtFormatsTo(
682 'var l = [1,];',
683 'var l = [1,];'
684 );
685 });
674 686
675 test('stmt (maps)', () { 687 test('stmt (maps)', () {
676 expectStmtFormatsTo( 688 expectStmtFormatsTo(
677 'var map = const {"foo": "bar", "fuz": null};', 689 'var map = const {"foo": "bar", "fuz": null};',
678 'var map = const {"foo": "bar", "fuz": null};' 690 'var map = const {"foo": "bar", "fuz": null};'
679 ); 691 );
692
693 //Dangling ','
694 expectStmtFormatsTo(
695 'var map = {"foo": "bar",};',
696 'var map = {"foo": "bar",};'
697 );
680 }); 698 });
681 699
682 test('stmt (try/catch)', () { 700 test('stmt (try/catch)', () {
683 expectStmtFormatsTo( 701 expectStmtFormatsTo(
684 'try {\n' 702 'try {\n'
685 'doSomething();\n' 703 'doSomething();\n'
686 '} catch (e) {\n' 704 '} catch (e) {\n'
687 'print(e);\n' 705 'print(e);\n'
688 '}', 706 '}',
689 'try {\n' 707 'try {\n'
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 new TokenStreamComparator(null, t1, t2).verifyEquals(); 968 new TokenStreamComparator(null, t1, t2).verifyEquals();
951 969
952 expectStreamsNotEqual(Token t1, Token t2) => 970 expectStreamsNotEqual(Token t1, Token t2) =>
953 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), 971 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(),
954 throwsA(new isInstanceOf<FormatterException>())); 972 throwsA(new isInstanceOf<FormatterException>()));
955 973
956 expectCUFormatsTo(src, expected) => expect(formatCU(src), equals(expected)); 974 expectCUFormatsTo(src, expected) => expect(formatCU(src), equals(expected));
957 975
958 expectStmtFormatsTo(src, expected) => expect(formatStatement(src), 976 expectStmtFormatsTo(src, expected) => expect(formatStatement(src),
959 equals(expected)); 977 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