| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 equals("var i = 1;\n")); | 111 equals("var i = 1;\n")); |
| 112 }); | 112 }); |
| 113 | 113 |
| 114 test('defaults to \\n if there are no newlines', () { | 114 test('defaults to \\n if there are no newlines', () { |
| 115 expect(new DartFormatter().format("var i =1;"), equals("var i = 1;\n")); | 115 expect(new DartFormatter().format("var i =1;"), equals("var i = 1;\n")); |
| 116 }); | 116 }); |
| 117 | 117 |
| 118 test('handles Windows line endings in multiline strings', () { | 118 test('handles Windows line endings in multiline strings', () { |
| 119 expect( | 119 expect( |
| 120 new DartFormatter(lineEnding: "\r\n").formatStatement(' """first\r\n' | 120 new DartFormatter(lineEnding: "\r\n").formatStatement(' """first\r\n' |
| 121 'second\r\n' | 121 'second\r\n' |
| 122 'third""" ;'), equals('"""first\r\n' | 122 'third""" ;'), equals('"""first\r\n' |
| 123 'second\r\n' | 123 'second\r\n' |
| 124 'third""";')); | 124 'third""";')); |
| 125 }); | 125 }); |
| 126 }); | 126 }); |
| 127 } | 127 } |
| 128 | 128 |
| 129 /// Run tests defined in "*.unit" and "*.stmt" files inside directory [name]. | 129 /// Run tests defined in "*.unit" and "*.stmt" files inside directory [name]. |
| 130 void testDirectory(String name) { | 130 void testDirectory(String name) { |
| 131 var indentPattern = new RegExp(r"^\(indent (\d+)\)\s*"); | 131 var indentPattern = new RegExp(r"^\(indent (\d+)\)\s*"); |
| 132 | 132 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 source = source.replaceAll("‹", ""); | 220 source = source.replaceAll("‹", ""); |
| 221 | 221 |
| 222 var end = source.indexOf("›"); | 222 var end = source.indexOf("›"); |
| 223 source = source.replaceAll("›", ""); | 223 source = source.replaceAll("›", ""); |
| 224 | 224 |
| 225 return new SourceCode(source, | 225 return new SourceCode(source, |
| 226 isCompilationUnit: isCompilationUnit, | 226 isCompilationUnit: isCompilationUnit, |
| 227 selectionStart: start == -1 ? null : start, | 227 selectionStart: start == -1 ? null : start, |
| 228 selectionLength: end == -1 ? null : end - start); | 228 selectionLength: end == -1 ? null : end - start); |
| 229 } | 229 } |
| OLD | NEW |