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

Side by Side Diff: client/testing/unittest/unittest.dart

Issue 9022042: Hacking format of Expect failure messages to play nice with rendered HTML. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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
« no previous file with comments | « no previous file | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * A simple unit test library for running tests in a browser. 6 * A simple unit test library for running tests in a browser.
7 */ 7 */
8 #library("unittest"); 8 #library("unittest");
9 9
10 #import("dart:dom"); 10 #import("dart:dom");
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 <td>${test_.id}</td> 85 <td>${test_.id}</td>
86 <td class="unittest-error">NO STATUS</td> 86 <td class="unittest-error">NO STATUS</td>
87 <td>Test did not complete</td> 87 <td>Test did not complete</td>
88 </tr>'''; 88 </tr>''';
89 } 89 }
90 90
91 var html = ''' 91 var html = '''
92 <tr> 92 <tr>
93 <td>${test_.id}</td> 93 <td>${test_.id}</td>
94 <td class="unittest-${test_.result}">${test_.result.toUpperCase()}</td> 94 <td class="unittest-${test_.result}">${test_.result.toUpperCase()}</td>
95 <td>Expectation: ${test_.description}. ${test_.message}</td> 95 <td>Expectation: ${test_.description}. ${_sanitize(test_.message)}</td>
96 </tr>'''; 96 </tr>''';
97 97
98 if (test_.stackTrace != null) { 98 if (test_.stackTrace != null) {
99 html += 99 html +=
100 '<tr><td></td><td colspan="2"><pre>${test_.stackTrace}</pre></td></tr>'; 100 '<tr><td></td><td colspan="2"><pre>${_sanitize(test_.stackTrace)}</pre>< /td></tr>';
101 } 101 }
102 102
103 return html; 103 return html;
104 } 104 }
105
106 String _sanitize(String string) {
Siggi Cherem (dart-lang) 2012/01/04 16:28:36 _sanitize -> _htmlEscape ?
107 return string.replaceAll('<','&lt;').replaceAll('>','&gt;');
Siggi Cherem (dart-lang) 2012/01/04 16:28:36 add also '&amp;'
108 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698