| 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 @TestOn("vm") | 5 @TestOn("vm") |
| 6 library dart_style.test.formatter_test; | 6 library dart_style.test.formatter_test; |
| 7 | 7 |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 expect( | 125 expect( |
| 126 new DartFormatter(lineEnding: "\r\n").formatStatement(' """first\r\n' | 126 new DartFormatter(lineEnding: "\r\n").formatStatement(' """first\r\n' |
| 127 'second\r\n' | 127 'second\r\n' |
| 128 'third""" ;'), | 128 'third""" ;'), |
| 129 equals('"""first\r\n' | 129 equals('"""first\r\n' |
| 130 'second\r\n' | 130 'second\r\n' |
| 131 'third""";')); | 131 'third""";')); |
| 132 }); | 132 }); |
| 133 }); | 133 }); |
| 134 | 134 |
| 135 test('throws a FormatterException on non-whitespace changes', () { | 135 test('throws an UnexpectedOutputException on non-whitespace changes', () { |
| 136 // Use an invalid line ending character to ensure the formatter will | 136 // Use an invalid line ending character to ensure the formatter will |
| 137 // attempt to make non-whitespace changes. | 137 // attempt to make non-whitespace changes. |
| 138 var formatter = new DartFormatter(lineEnding: '%'); | 138 var formatter = new DartFormatter(lineEnding: '%'); |
| 139 expect(() => formatter.format("var i = 1;"), | 139 expect(() => formatter.format("var i = 1;"), |
| 140 throwsA(new isInstanceOf<FormatException>())); | 140 throwsA(new isInstanceOf<UnexpectedOutputException>())); |
| 141 }); | 141 }); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /// Run tests defined in "*.unit" and "*.stmt" files inside directory [name]. | 144 /// Run tests defined in "*.unit" and "*.stmt" files inside directory [name]. |
| 145 void testDirectory(String name) { | 145 void testDirectory(String name) { |
| 146 var indentPattern = new RegExp(r"^\(indent (\d+)\)\s*"); | 146 var indentPattern = new RegExp(r"^\(indent (\d+)\)\s*"); |
| 147 | 147 |
| 148 // Locate the "test" directory. Use mirrors so that this works with the test | 148 // Locate the "test" directory. Use mirrors so that this works with the test |
| 149 // package, which loads this suite into an isolate. | 149 // package, which loads this suite into an isolate. |
| 150 var testDir = p.dirname(currentMirrorSystem() | 150 var testDir = p.dirname(currentMirrorSystem() |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 source = source.replaceAll("‹", ""); | 248 source = source.replaceAll("‹", ""); |
| 249 | 249 |
| 250 var end = source.indexOf("›"); | 250 var end = source.indexOf("›"); |
| 251 source = source.replaceAll("›", ""); | 251 source = source.replaceAll("›", ""); |
| 252 | 252 |
| 253 return new SourceCode(source, | 253 return new SourceCode(source, |
| 254 isCompilationUnit: isCompilationUnit, | 254 isCompilationUnit: isCompilationUnit, |
| 255 selectionStart: start == -1 ? null : start, | 255 selectionStart: start == -1 ? null : start, |
| 256 selectionLength: end == -1 ? null : end - start); | 256 selectionLength: end == -1 ? null : end - start); |
| 257 } | 257 } |
| OLD | NEW |