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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/audit.js

Issue 2595393003: Handle should.throw() assertion with no argument properly (Closed)
Patch Set: Created 3 years, 12 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 | « no previous file | third_party/WebKit/LayoutTests/webaudio/unit-tests/audit.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileOverview WebAudio layout test utility library. Built around W3C's 7 * @fileOverview WebAudio layout test utility library. Built around W3C's
8 * testharness.js. Includes asynchronous test task manager, 8 * testharness.js. Includes asynchronous test task manager,
9 * assertion utilities. 9 * assertion utilities.
10 * @dependency testharness.js 10 * @dependency testharness.js
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 let didThrowCorrectly = false; 264 let didThrowCorrectly = false;
265 let passDetail, failDetail; 265 let passDetail, failDetail;
266 266
267 try { 267 try {
268 // This should throw. 268 // This should throw.
269 this._actual(); 269 this._actual();
270 // Catch did not happen, so the test is failed. 270 // Catch did not happen, so the test is failed.
271 failDetail = '${actual} did not throw an exception.'; 271 failDetail = '${actual} did not throw an exception.';
272 } catch (error) { 272 } catch (error) {
273 if (this._expected === undefined) { 273 if (this._expected === null) {
Raymond Toy 2016/12/22 17:55:00 What if someone did should(...).throw(undefined)
hongchan 2016/12/22 18:10:31 Giving |undefined| as an argument will do nothing.
274 // The expected error type was not given.
274 didThrowCorrectly = true; 275 didThrowCorrectly = true;
275 passDetail = '${actual} threw an exception of ' + error.name + '.'; 276 passDetail = '${actual} threw an exception of ' + error.name + ': "'
277 + error.message + '".';
Raymond Toy 2016/12/22 17:55:00 Nit: Can we actually throw anything other than an
hongchan 2016/12/22 18:10:31 Good call. Done.
276 } else if (error.name === this._expected) { 278 } else if (error.name === this._expected) {
279 // The expected error type match the actual one.
277 didThrowCorrectly = true; 280 didThrowCorrectly = true;
278 passDetail = '${actual} threw ${expected} : "' + error.message + '".'; 281 passDetail = '${actual} threw ${expected} as expected: "'
282 + error.message + '".';
Raymond Toy 2016/12/22 17:55:00 Nit: Similarly, can we just say "threw expected $
hongchan 2016/12/22 18:10:31 Sure. Done.
279 } else { 283 } else {
280 didThrowCorrectly = false; 284 didThrowCorrectly = false;
281 failDetail = '${actual} threw "' + error.name 285 failDetail = '${actual} threw "' + error.name
282 + '" instead of ${expected}.'; 286 + '" instead of ${expected}.';
283 } 287 }
284 } 288 }
285 289
286 return this._assert(didThrowCorrectly, passDetail, failDetail); 290 return this._assert(didThrowCorrectly, passDetail, failDetail);
287 } 291 }
288 292
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 _logError('this test requires the explicit comparison with the ' 1030 _logError('this test requires the explicit comparison with the '
1027 + 'expected result when it runs with run-webkit-tests.'); 1031 + 'expected result when it runs with run-webkit-tests.');
1028 } 1032 }
1029 1033
1030 return new TaskRunner(); 1034 return new TaskRunner();
1031 } 1035 }
1032 1036
1033 }; 1037 };
1034 1038
1035 })(); 1039 })();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/unit-tests/audit.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698