OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart_style.test.formatter_test; | 5 library dart_style.test.formatter_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } else { | 158 } else { |
159 result = formatter.format(input); | 159 result = formatter.format(input); |
160 } | 160 } |
161 | 161 |
162 expect(result, equals(expectedOutput)); | 162 expect(result, equals(expectedOutput)); |
163 }); | 163 }); |
164 } | 164 } |
165 }); | 165 }); |
166 } | 166 } |
167 } | 167 } |
168 | |
169 // TODO(rnystrom): These tests are from when the formatter would make | |
170 // non-whitespace changes. Eventually, when style linting is supported, these | |
171 // should become linting errors. | |
172 /* | |
173 >>> DO use ; instead of {} for empty constructor bodies | |
174 class Point { | |
175 int x, y; | |
176 Point(this.x, this.y) {} | |
177 } | |
178 <<< | |
179 class Point { | |
180 int x, y; | |
181 Point(this.x, this.y); | |
182 } | |
183 >>> DO use curly braces for all flow control structures. | |
184 flow() { | |
185 if (true) print('sanity'); | |
186 else | |
187 print('opposite day!'); | |
188 } | |
189 <<< | |
190 flow() { | |
191 if (true) { | |
192 print('sanity'); | |
193 } else { | |
194 print('opposite day!'); | |
195 } | |
196 } | |
197 | |
198 test('CU (empty ctor bodies)', () { | |
199 expectCUFormatsTo( | |
200 'class A {\n' | |
201 ' A() {\n' | |
202 ' }\n' | |
203 '}\n', | |
204 'class A {\n' | |
205 ' A();\n' | |
206 '}\n' | |
207 ); | |
208 expectCUFormatsTo( | |
209 'class A {\n' | |
210 ' A() {\n' | |
211 ' }\n' | |
212 '}\n', | |
213 'class A {\n' | |
214 ' A();\n' | |
215 '}\n' | |
216 ); | |
217 }); | |
218 | |
219 */ | |
OLD | NEW |