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

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

Issue 16562012: Dart formatter babysteps. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:analyzer_experimental/src/generated/ast.dart';
6 import 'package:analyzer_experimental/src/services/formatter.dart';
7 import 'package:analyzer_experimental/src/services/formatter_impl.dart';
8 import 'package:unittest/unittest.dart';
9
10 main() {
11
12 /// Edit recorder tests
13 group('edit recorder', () {
messick 2013/06/07 13:51:36 I'd add a few tests that are expected to fail.
pquitslund 2013/06/07 19:45:01 Will do. Thanks!
14
15 test('countWhitespace', (){
16 expect(newRecorder(' ').countWhitespace(), equals(3));
17 expect(newRecorder('').countWhitespace(), equals(0));
18 expect(newRecorder(' foo').countWhitespace(), equals(2));
19 });
20
21 test('indent', (){
22 var recorder = newRecorder('');
23 expect(recorder.indentationLevel, equals(0));
24 expect(recorder.options.indentPerLevel, equals(2));
25 recorder.indent();
26 expect(recorder.indentationLevel, equals(2));
27 expect(recorder.numberOfIndentations, equals(1));
28 });
29
30 test('isNewlineAt', (){
31 expect(newRecorder('012\n').isNewlineAt(3), isTrue);
32 expect(newRecorder('012\n3456').isNewlineAt(3), isTrue);
33 expect(newRecorder('\n').isNewlineAt(0), isTrue);
34 });
35
36 });
37
38
39 /// Formatter tests
40 group('formatter', () {
41
42 test('failedParse', () {
43 var formatter = new CodeFormatter();
44 expect(() => formatter.format(CodeKind.COMPILATION_UNIT, "~"),
45 throwsA(new isInstanceOf<FormatterException>('FE')));
46 });
47
48 // test('initialIndent', () {
49 // var formatter = new CodeFormatter(new Options(initialIndentationLevel:2) );
50 // var formattedSource = formatter.format(CodeKind.STATEMENT, 'var x;');
51 // expect(formattedSource, startsWith(' '));
52 // });
53
54 });
55
56 }
57
58 EditRecorder newRecorder(String source) {
59 var recorder = new EditRecorder(new FormatterOptions());
60 recorder.source = source;
61 return recorder;
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698