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

Unified Diff: pkg/analyzer_experimental/test/services/formatter_test.dart

Issue 22403004: Formatter checkpoint. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_experimental/lib/src/services/writer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_experimental/test/services/formatter_test.dart
===================================================================
--- pkg/analyzer_experimental/test/services/formatter_test.dart (revision 25934)
+++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
@@ -4,9 +4,7 @@
import 'package:unittest/unittest.dart';
-import 'package:analyzer_experimental/src/generated/ast.dart';
import 'package:analyzer_experimental/src/generated/scanner.dart';
-import 'package:analyzer_experimental/src/services/formatter.dart';
import 'package:analyzer_experimental/src/services/formatter_impl.dart';
import 'package:analyzer_experimental/src/services/writer.dart';
@@ -57,6 +55,20 @@
);
});
+ test('CU w/class decl comment', () {
+ expectCUFormatsTo(
+ 'import "foo";\n\n'
+ '//Killer class\n'
+ 'class A {\n'
+ '}',
+ 'import "foo";\n\n'
+ '//Killer class\n'
+ 'class A {\n'
+ '}\n'
+ );
+ });
+
+
test('CU (method indent)', () {
expectCUFormatsTo(
'class A {\n'
@@ -99,7 +111,7 @@
'class A {\n'
' int x() { \n'
'if (true) {return 42;\n'
- '} else { return false; }\n'
+ '} else { return 13; }\n'
' }'
'}',
'class A {\n'
@@ -107,7 +119,7 @@
' if (true) {\n'
' return 42;\n'
' } else {\n'
- ' return false;\n'
+ ' return 13;\n'
' }\n'
' }\n'
'}\n'
@@ -131,15 +143,18 @@
expectCUFormatsTo(
'class A {\n'
'}\n\n'
- 'class B {\n'
+ 'class B {\n\n\n'
+ ' int b() => 42;\n\n'
+ ' int c() => b();\n\n'
'}\n',
'class A {\n'
'}\n\n'
- 'class B {\n'
+ 'class B {\n\n\n'
+ ' int b() => 42;\n\n'
+ ' int c() => b();\n\n'
'}\n'
);
});
-
test('stmt', () {
expectStmtFormatsTo(
@@ -168,7 +183,6 @@
);
});
-
test('initialIndent', () {
var formatter = new CodeFormatter(
new FormatterOptions(initialIndentationLevel: 2));
@@ -210,6 +224,11 @@
expect(line.toString(), equals(' foo'));
});
+ test('isWhitespace', () {
+ var line = new Line(indent: 1);
+ expect(line.isWhitespace(), isTrue);
+ });
+
});
@@ -231,6 +250,12 @@
expect(writer.toString(), equals('foo\n'));
});
+ test('newline trims whitespace', () {
+ var writer = new SourceWriter(indentCount:2);
+ writer.newline();
+ expect(writer.toString(), equals('\n'));
+ });
+
test('basic print (with indents)', () {
var writer = new SourceWriter();
writer.print('foo');
« no previous file with comments | « pkg/analyzer_experimental/lib/src/services/writer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698