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

Side by Side Diff: test/formatter_test.dart

Issue 2427063003: Fix test to not depend on analyzer error message. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 test("does not add newline to statement", () { 74 test("does not add newline to statement", () {
75 expect(new DartFormatter().formatStatement("var x = 1;"), 75 expect(new DartFormatter().formatStatement("var x = 1;"),
76 equals("var x = 1;")); 76 equals("var x = 1;"));
77 }); 77 });
78 78
79 test("fails if anything is after the statement", () { 79 test("fails if anything is after the statement", () {
80 try { 80 try {
81 new DartFormatter().formatStatement("var x = 1;;"); 81 new DartFormatter().formatStatement("var x = 1;;");
82 82
83 fail("Should throw."); 83 fail("Should throw.");
84 } catch (err) { 84 } on FormatterException catch (ex) {
85 expect(err, new isInstanceOf<FormatterException>()); 85 expect(ex.errors.length, equals(1));
86 var message = err.message(); 86 expect(ex.errors.first.offset, equals(10));
87 expect(message, contains("Unexpected token"));
88 expect(message, contains("column 11"));
89 } 87 }
90 }); 88 });
91 89
92 test('preserves initial indent', () { 90 test('preserves initial indent', () {
93 var formatter = new DartFormatter(indent: 3); 91 var formatter = new DartFormatter(indent: 3);
94 expect( 92 expect(
95 formatter.formatStatement('if (foo) {bar;}'), 93 formatter.formatStatement('if (foo) {bar;}'),
96 equals(' if (foo) {\n' 94 equals(' if (foo) {\n'
97 ' bar;\n' 95 ' bar;\n'
98 ' }')); 96 ' }'));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 source = source.replaceAll("‹", ""); 229 source = source.replaceAll("‹", "");
232 230
233 var end = source.indexOf("›"); 231 var end = source.indexOf("›");
234 source = source.replaceAll("›", ""); 232 source = source.replaceAll("›", "");
235 233
236 return new SourceCode(source, 234 return new SourceCode(source,
237 isCompilationUnit: isCompilationUnit, 235 isCompilationUnit: isCompilationUnit,
238 selectionStart: start == -1 ? null : start, 236 selectionStart: start == -1 ? null : start,
239 selectionLength: end == -1 ? null : end - start); 237 selectionLength: end == -1 ? null : end - start);
240 } 238 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698