Some fixes in unittest after io v2

Review URL: https://codereview.chromium.org//12316072

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18899 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
sigmund@google.com 2013-02-22 17:34:17 +00:00
parent 3464bf935c
commit 55cfa2d3d5
3 changed files with 28 additions and 28 deletions

View file

@ -89,24 +89,24 @@ class CompactVMConfiguration extends VMConfiguration {
var duration = (new DateTime.now()).difference(startTime);
var buffer = new StringBuffer();
// \r moves back to the beginnig of the current line.
buffer.add('\r${_timeString(duration)} ');
buffer.add(_GREEN);
buffer.add('+');
buffer.add(passed);
buffer.add(_NONE);
if (failed != 0) buffer.add(_RED);
buffer.add(' -');
buffer.add(failed);
if (failed != 0) buffer.add(_NONE);
buffer.add(': ');
buffer.add(color);
buffer.write('\r${_timeString(duration)} ');
buffer.write(_GREEN);
buffer.write('+');
buffer.write(passed);
buffer.write(_NONE);
if (failed != 0) buffer.write(_RED);
buffer.write(' -');
buffer.write(failed);
if (failed != 0) buffer.write(_NONE);
buffer.write(': ');
buffer.write(color);
int nonVisible = _nonVisiblePrefix + color.length +
(failed != 0 ? (_RED.length + _NONE.length) : 0);
int len = buffer.length - nonVisible;
var mx = MAX_LINE - len;
buffer.add(_snippet(message, MAX_LINE - len));
buffer.add(_NONE);
buffer.write(_snippet(message, MAX_LINE - len));
buffer.write(_NONE);
// Pad the rest of the line so that it looks erased.
len = buffer.length - nonVisible - _NONE.length;
@ -114,11 +114,11 @@ class CompactVMConfiguration extends VMConfiguration {
_lastLength = len;
} else {
while (len < _lastLength) {
buffer.add(' ');
buffer.write(' ');
_lastLength--;
}
}
stdout.writeString(buffer.toString());
stdout.addString(buffer.toString());
}
String _padTime(int time) =>
@ -146,11 +146,11 @@ class CompactVMConfiguration extends VMConfiguration {
if (i < words.length - 4) {
// Require at least 3 words at the end.
var buffer = new StringBuffer();
buffer.add(words.first);
buffer.add(' ...');
buffer.write(words.first);
buffer.write(' ...');
for (; i < words.length; i++) {
buffer.add(' ');
buffer.add(words[i]);
buffer.write(' ');
buffer.write(words[i]);
}
return buffer.toString();
}

View file

@ -18,17 +18,17 @@ void _showResultsInPage(int passed, int failed, int errors,
document.body.innerHtml = "PASS";
} else {
var newBody = new StringBuffer();
newBody.add("<table class='unittest-table'><tbody>");
newBody.add(passed == results.length && uncaughtError == null
newBody.write("<table class='unittest-table'><tbody>");
newBody.write(passed == results.length && uncaughtError == null
? "<tr><td colspan='3' class='unittest-pass'>PASS</td></tr>"
: "<tr><td colspan='3' class='unittest-fail'>FAIL</td></tr>");
for (final test_ in results) {
newBody.add(_toHtml(test_));
newBody.write(_toHtml(test_));
}
if (uncaughtError != null) {
newBody.add('''<tr>
newBody.write('''<tr>
<td>--</td>
<td class="unittest-error">ERROR</td>
<td>Uncaught error: $uncaughtError</td>
@ -36,12 +36,12 @@ void _showResultsInPage(int passed, int failed, int errors,
}
if (passed == results.length && uncaughtError == null) {
newBody.add("""
newBody.write("""
<tr><td colspan='3' class='unittest-pass'>
All ${passed} tests passed
</td></tr>""");
} else {
newBody.add("""
newBody.write("""
<tr><td colspan='3'>Total
<span class='unittest-pass'>${passed} passed</span>,
<span class='unittest-fail'>${failed} failed</span>
@ -49,7 +49,7 @@ void _showResultsInPage(int passed, int failed, int errors,
${errors + (uncaughtError == null ? 0 : 1)} errors</span>
</td></tr>""");
}
newBody.add("</tbody></table>");
newBody.write("</tbody></table>");
document.body.innerHtml = newBody.toString();
}
}

View file

@ -74,11 +74,11 @@ String collapseWhitespace(_string) {
var character = _string[i];
if (isWhitespace(character)) {
if (!skipSpace) {
result.add(' ');
result.write(' ');
skipSpace = true;
}
} else {
result.add(character);
result.write(character);
skipSpace = false;
}
}