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

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

Issue 22937006: Formatter token emission baby-steps. (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/formatter_impl.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 26042)
+++ pkg/analyzer_experimental/test/services/formatter_test.dart (working copy)
@@ -183,6 +183,69 @@
);
});
+ test('stmt (switch)', () {
+ expectStmtFormatsTo(
+ 'switch (fruit) {\n'
+ 'case "apple":\n'
+ 'print("delish");\n'
+ 'break;\n'
+ 'case "fig":\n'
+ 'print("bleh");\n'
+ 'break;\n'
+ '}\n',
+ 'switch (fruit) {\n'
+ ' case "apple":\n'
+ ' print("delish");\n'
+ ' break;\n'
+ ' case "fig":\n'
+ ' print("bleh");\n'
+ ' break;\n'
+ '}\n'
+ );
+ });
+
+ test('stmt (generics)', () {
+ expectStmtFormatsTo(
+ 'var numbers = <int>[1, 2, (3 + 4)];',
+ 'var numbers = <int>[1, 2, (3 + 4)];'
+ );
+ });
+
+ test('stmt (try/catch)', () {
+ expectStmtFormatsTo(
+ 'try {\n'
+ 'doSomething();\n'
+ '} catch (e) {\n'
+ 'print(e);\n'
+ '}\n',
+ 'try {\n'
+ ' doSomething();\n'
+ '} catch (e) {\n'
+ ' print(e);\n'
+ '}\n'
+ );
+ });
+
+
+ test('stmt (binary/ternary ops)', () {
+ expectStmtFormatsTo(
+ 'var a = 1 + 2 / (3 * -b);',
+ 'var a = 1 + 2 / (3 * -b);'
+ );
+ expectStmtFormatsTo(
+ 'var c = !condition == a > b;',
+ 'var c = !condition == a > b;'
+ );
+ expectStmtFormatsTo(
+ 'var d = condition ? b : object.method(a, b, c);',
+ 'var d = condition ? b : object.method(a, b, c);'
+ );
+ expectStmtFormatsTo(
+ 'var d = obj is! SomeType;',
+ 'var d = obj is! SomeType;'
+ );
+ });
+
test('initialIndent', () {
var formatter = new CodeFormatter(
new FormatterOptions(initialIndentationLevel: 2));
« 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