| OLD | NEW |
| 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/src/generated/java_core.dart' show CharSequence; | 7 import 'package:analyzer/src/generated/java_core.dart' show CharSequence; |
| 8 import 'package:analyzer/src/generated/scanner.dart'; | 8 import 'package:analyzer/src/generated/scanner.dart'; |
| 9 import 'package:analyzer/src/services/formatter_impl.dart'; | 9 import 'package:analyzer/src/services/formatter_impl.dart'; |
| 10 import 'package:analyzer/src/services/writer.dart'; | 10 import 'package:analyzer/src/services/writer.dart'; |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 'doSomething();\n' | 829 'doSomething();\n' |
| 830 '} catch (e) {\n' | 830 '} catch (e) {\n' |
| 831 'print(e);\n' | 831 'print(e);\n' |
| 832 '}', | 832 '}', |
| 833 'try {\n' | 833 'try {\n' |
| 834 ' doSomething();\n' | 834 ' doSomething();\n' |
| 835 '} catch (e) {\n' | 835 '} catch (e) {\n' |
| 836 ' print(e);\n' | 836 ' print(e);\n' |
| 837 '}' | 837 '}' |
| 838 ); | 838 ); |
| 839 expectStmtFormatsTo( |
| 840 'try{\n' |
| 841 'doSomething();\n' |
| 842 '}on Exception catch (e){\n' |
| 843 'print(e);\n' |
| 844 '}', |
| 845 'try {\n' |
| 846 ' doSomething();\n' |
| 847 '} on Exception catch (e) {\n' |
| 848 ' print(e);\n' |
| 849 '}' |
| 850 ); |
| 839 }); | 851 }); |
| 840 | 852 |
| 841 test('stmt (binary/ternary ops)', () { | 853 test('stmt (binary/ternary ops)', () { |
| 842 expectStmtFormatsTo( | 854 expectStmtFormatsTo( |
| 843 'var a = 1 + 2 / (3 * -b);', | 855 'var a = 1 + 2 / (3 * -b);', |
| 844 'var a = 1 + 2 / (3 * -b);' | 856 'var a = 1 + 2 / (3 * -b);' |
| 845 ); | 857 ); |
| 846 expectStmtFormatsTo( | 858 expectStmtFormatsTo( |
| 847 'var c = !condition == a > b;', | 859 'var c = !condition == a > b;', |
| 848 'var c = !condition == a > b;' | 860 'var c = !condition == a > b;' |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), | 1148 expect(() => new TokenStreamComparator(null, t1, t2).verifyEquals(), |
| 1137 throwsA(new isInstanceOf<FormatterException>())); | 1149 throwsA(new isInstanceOf<FormatterException>())); |
| 1138 | 1150 |
| 1139 expectCUFormatsTo(src, expected, {transforms: true}) => | 1151 expectCUFormatsTo(src, expected, {transforms: true}) => |
| 1140 expect(formatCU(src, options: new FormatterOptions( | 1152 expect(formatCU(src, options: new FormatterOptions( |
| 1141 codeTransforms: transforms)).source, equals(expected)); | 1153 codeTransforms: transforms)).source, equals(expected)); |
| 1142 | 1154 |
| 1143 expectStmtFormatsTo(src, expected, {transforms: true}) => | 1155 expectStmtFormatsTo(src, expected, {transforms: true}) => |
| 1144 expect(formatStatement(src, options: | 1156 expect(formatStatement(src, options: |
| 1145 new FormatterOptions(codeTransforms: transforms)), equals(expected)); | 1157 new FormatterOptions(codeTransforms: transforms)), equals(expected)); |
| OLD | NEW |