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

Side by Side Diff: pkg/scheduled_test/test/metatest.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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 /// A test library for testing test libraries? We must go deeper. 5 /// A test library for testing test libraries? We must go deeper.
6 /// 6 ///
7 /// Since unit testing code tends to use a lot of global state, it can be tough 7 /// Since unit testing code tends to use a lot of global state, it can be tough
8 /// to test. This library manages it by running each test case in a child 8 /// to test. This library manages it by running each test case in a child
9 /// isolate, then reporting the results back to the parent isolate. 9 /// isolate, then reporting the results back to the parent isolate.
10 library metatest; 10 library metatest;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 /// an error occurred. 130 /// an error occurred.
131 bool _hasError(Map results) { 131 bool _hasError(Map results) {
132 return results['errors'] > 0 || results['uncaughtError'] != null || 132 return results['errors'] > 0 || results['uncaughtError'] != null ||
133 (results['passed'] == 0 && results['failed'] == 0); 133 (results['passed'] == 0 && results['failed'] == 0);
134 } 134 }
135 135
136 /// Returns a string description of the test run descibed by [results]. 136 /// Returns a string description of the test run descibed by [results].
137 String _summarizeTests(Map results) { 137 String _summarizeTests(Map results) {
138 var buffer = new StringBuffer(); 138 var buffer = new StringBuffer();
139 for (var t in results["results"]) { 139 for (var t in results["results"]) {
140 buffer.add("${t['result'].toUpperCase()}: ${t['description']}\n"); 140 buffer.writeln("${t['result'].toUpperCase()}: ${t['description']}");
141 if (t['message'] != '') buffer.add("${_indent(t['message'])}\n"); 141 if (t['message'] != '') buffer.writeln("${_indent(t['message'])}");
142 if (t['stackTrace'] != null && t['stackTrace'] != '') { 142 if (t['stackTrace'] != null && t['stackTrace'] != '') {
143 buffer.add("${_indent(t['stackTrace'])}\n"); 143 buffer.writeln("${_indent(t['stackTrace'])}");
144 } 144 }
145 } 145 }
146 146
147 buffer.add("\n"); 147 buffer.writeln("");
148 148
149 var success = false; 149 var success = false;
150 if (results['passed'] == 0 && results['failed'] == 0 && 150 if (results['passed'] == 0 && results['failed'] == 0 &&
151 results['errors'] == 0 && results['uncaughtError'] == null) { 151 results['errors'] == 0 && results['uncaughtError'] == null) {
152 buffer.add('No tests found.'); 152 buffer.write('No tests found.');
153 // This is considered a failure too. 153 // This is considered a failure too.
154 } else if (results['failed'] == 0 && results['errors'] == 0 && 154 } else if (results['failed'] == 0 && results['errors'] == 0 &&
155 results['uncaughtError'] == null) { 155 results['uncaughtError'] == null) {
156 buffer.add('All ${results['passed']} tests passed.'); 156 buffer.write('All ${results['passed']} tests passed.');
157 success = true; 157 success = true;
158 } else { 158 } else {
159 if (results['uncaughtError'] != null) { 159 if (results['uncaughtError'] != null) {
160 buffer.add('Top-level uncaught error: ${results['uncaughtError']}'); 160 buffer.write('Top-level uncaught error: ${results['uncaughtError']}');
161 } 161 }
162 buffer.add('${results['passed']} PASSED, ${results['failed']} FAILED, ' 162 buffer.write('${results['passed']} PASSED, ${results['failed']} FAILED, '
163 '${results['errors']} ERRORS'); 163 '${results['errors']} ERRORS');
164 } 164 }
165 return prefixLines(buffer.toString()); 165 return prefixLines(buffer.toString());
166 } 166 }
167 167
168 /// Indents each line of [str] by two spaces. 168 /// Indents each line of [str] by two spaces.
169 String _indent(String str) { 169 String _indent(String str) {
170 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. 170 // TODO(nweiz): Use this simpler code once issue 2980 is fixed.
171 // return str.replaceAll(new RegExp("^", multiLine: true), " "); 171 // return str.replaceAll(new RegExp("^", multiLine: true), " ");
172 172
(...skipping 24 matching lines...) Expand all
197 "message": testCase.message, 197 "message": testCase.message,
198 "result": testCase.result, 198 "result": testCase.result,
199 "stackTrace": testCase.stackTrace 199 "stackTrace": testCase.stackTrace
200 }).toList() 200 }).toList()
201 }); 201 });
202 } 202 }
203 203
204 void onInit() {} 204 void onInit() {}
205 void onDone(bool success) {} 205 void onDone(bool success) {}
206 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698