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

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

Issue 2654673003: Implement should().beRejectedWith() (Closed)
Patch Set: Initial patch Created 3 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
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 beRejected () { 350 beRejected () {
351 return this._actual.then(function () { 351 return this._actual.then(function () {
352 this._assert(false, null, '${actual} resolved incorrectly.'); 352 this._assert(false, null, '${actual} resolved incorrectly.');
353 }.bind(this), function (error) { 353 }.bind(this), function (error) {
354 this._assert(true, 354 this._assert(true,
355 '${actual} rejected correctly with ' + error + '.', null); 355 '${actual} rejected correctly with ' + error + '.', null);
356 }.bind(this)); 356 }.bind(this));
357 } 357 }
358 358
359 /** 359 /**
360 * Check if |actual| promise is rejected correctly.
361 *
362 * @example
363 * should('My promise', promise).beRejectedWith('_ERROR_').then();
Raymond Toy 2017/01/23 23:11:57 This is backward, right? |promise| should be the f
hongchan 2017/01/23 23:14:50 Done.
364 *
365 * @result
366 * "PASS My promise rejected correctly with _ERROR_."
367 * "FAIL X My promise rejected correctly but got _ACTUAL_ERROR instead of
368 * _EXPECTED_ERROR_."
369 * "FAIL X My promise resolved incorrectly."
370 */
371 beRejectedWith() {
372 this._processArguments(arguments);
373
374 return this._actual.then(
375 function() {
376 this._assert(false, null, '${actual} resolved incorrectly.');
377 }.bind(this),
378 function(error) {
379 if (this._expected !== error.name) {
380 this._assert(
381 false, null, '${actual} rejected correctly but got ' +
382 error.name + ' instead of ' + this._expected + '.');
383 } else {
384 this._assert(
385 true,
386 '${actual} rejected correctly with ' + this._expected + '.',
387 null);
388 }
389 }.bind(this));
390 }
391
392 /**
360 * Check if |actual| is a boolean true. 393 * Check if |actual| is a boolean true.
361 * 394 *
362 * @example 395 * @example
363 * should(3 < 5, '3 < 5').beTrue(); 396 * should(3 < 5, '3 < 5').beTrue();
364 * 397 *
365 * @result 398 * @result
366 * "PASS 3 < 5 is true." 399 * "PASS 3 < 5 is true."
367 */ 400 */
368 beTrue () { 401 beTrue () {
369 return this._assert( 402 return this._assert(
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 _logError('this test requires the explicit comparison with the ' 1104 _logError('this test requires the explicit comparison with the '
1072 + 'expected result when it runs with run-webkit-tests.'); 1105 + 'expected result when it runs with run-webkit-tests.');
1073 } 1106 }
1074 1107
1075 return new TaskRunner(); 1108 return new TaskRunner();
1076 } 1109 }
1077 1110
1078 }; 1111 };
1079 1112
1080 })(); 1113 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698