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

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

Issue 26229004: Code formatter transform for empty constructor bodys (a la 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 '}\n', 631 '}\n',
632 'class X {\n' 632 'class X {\n'
633 ' var x, y;\n' 633 ' var x, y;\n'
634 ' X()\n' 634 ' X()\n'
635 ' : x = 1,\n' 635 ' : x = 1,\n'
636 ' y = 2;\n' 636 ' y = 2;\n'
637 '}\n' 637 '}\n'
638 ); 638 );
639 }); 639 });
640 640
641 test('CU (empty cons bodies)', () {
642 expectCUFormatsTo(
643 'class A {\n'
644 ' A() {\n'
645 ' }\n'
646 '}\n',
647 'class A {\n'
648 ' A();\n'
649 '}\n',
650 transforms: true
651 );
652 expectCUFormatsTo(
653 'class A {\n'
654 ' A() {\n'
655 ' }\n'
656 '}\n',
657 'class A {\n'
658 ' A() {\n'
659 ' }\n'
660 '}\n',
661 transforms: false
662 );
663 });
664
641 test('stmt', () { 665 test('stmt', () {
642 expectStmtFormatsTo( 666 expectStmtFormatsTo(
643 'if (true){\n' 667 'if (true){\n'
644 'if (true){\n' 668 'if (true){\n'
645 'if (true){\n' 669 'if (true){\n'
646 'return true;\n' 670 'return true;\n'
647 '} else{\n' 671 '} else{\n'
648 'return false;\n' 672 'return false;\n'
649 '}\n' 673 '}\n'
650 '}\n' 674 '}\n'
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 expect(()=> expectStreamsEqual(tokenize(s1), tokenize(s2)), 1045 expect(()=> expectStreamsEqual(tokenize(s1), tokenize(s2)),
1022 throwsA(new isInstanceOf<FormatterException>())); 1046 throwsA(new isInstanceOf<FormatterException>()));
1023 1047
1024 expectStreamsEqual(Token t1, Token t2) => 1048 expectStreamsEqual(Token t1, Token t2) =>
1025 new TokenStreamComparator(null, t1, t2).verifyEquals(); 1049 new TokenStreamComparator(null, t1, t2).verifyEquals();
1026 1050
1027 expectStreamsNotEqual(Token t1, Token t2) => 1051 expectStreamsNotEqual(Token t1, Token t2) =>
1028 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), 1052 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(),
1029 throwsA(new isInstanceOf<FormatterException>())); 1053 throwsA(new isInstanceOf<FormatterException>()));
1030 1054
1031 expectCUFormatsTo(src, expected) => 1055 expectCUFormatsTo(src, expected, {transforms: true}) =>
1032 expect(formatCU(src).source, equals(expected)); 1056 expect(formatCU(src, options: new FormatterOptions(
1057 codeTransforms: transforms)).source, equals(expected));
1033 1058
1034 expectStmtFormatsTo(src, expected, {transforms: true}) => 1059 expectStmtFormatsTo(src, expected, {transforms: true}) =>
1035 expect(formatStatement(src, options: 1060 expect(formatStatement(src, options:
1036 new FormatterOptions(codeTransforms: transforms)), equals(expected)); 1061 new FormatterOptions(codeTransforms: transforms)), 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