OLD | NEW |
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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 + ' more errors.'; | 534 + ' more errors.'; |
535 break; | 535 break; |
536 } | 536 } |
537 } | 537 } |
538 } | 538 } |
539 | 539 |
540 return this._assert(passed, passDetail, failDetail); | 540 return this._assert(passed, passDetail, failDetail); |
541 } | 541 } |
542 | 542 |
543 /** | 543 /** |
| 544 * Check if |actual| array is not filled with a constant |expected| value. |
| 545 * |
| 546 * @example |
| 547 * should([1, 0, 1]).notBeConstantValueOf(1); |
| 548 * should([0, 0, 0]).notBeConstantValueOf(0); |
| 549 * |
| 550 * @result |
| 551 * "PASS [1,0,1] is not constantly 1 (contains 1 different value)." |
| 552 * "FAIL X [0,0,0] should have contain at least one value different |
| 553 * from 0." |
| 554 */ |
| 555 notBeConstantValueOf () { |
| 556 this._processArguments(arguments); |
| 557 this._printActualForFailure = false; |
| 558 |
| 559 let passed = true; |
| 560 let passDetail; |
| 561 let failDetail; |
| 562 let differences = {}; |
| 563 |
| 564 for (let index in this._actual) { |
| 565 if (this._actual[index] !== this._expected) |
| 566 differences[index] = this._actual[index]; |
| 567 } |
| 568 |
| 569 let numberOfDifferences = Object.keys(differences).length; |
| 570 passed = numberOfDifferences > 0; |
| 571 |
| 572 if (passed) { |
| 573 let valueString = numberOfDifferences > 1 ? 'values' : 'value'; |
| 574 passDetail = '${actual} is not constantly ${expected} (contains ' + |
| 575 numberOfDifferences + ' different ' + valueString + ').'; |
| 576 } else { |
| 577 failDetail = '${actual} should have contain at least one value ' + |
| 578 'different from ${expected}.'; |
| 579 } |
| 580 |
| 581 return this._assert(passed, passDetail, failDetail); |
| 582 } |
| 583 |
| 584 /** |
544 * Check if |actual| array is identical to |expected| array element-wise. | 585 * Check if |actual| array is identical to |expected| array element-wise. |
545 * | 586 * |
546 * @example | 587 * @example |
547 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); | 588 * should([1, 2, 3]).beEqualToArray([1, 2, 3]); |
548 * | 589 * |
549 * @result | 590 * @result |
550 * "[1,2,3] is identical to the array [1,2,3]." | 591 * "[1,2,3] is identical to the array [1,2,3]." |
551 */ | 592 */ |
552 beEqualToArray () { | 593 beEqualToArray () { |
553 this._processArguments(arguments); | 594 this._processArguments(arguments); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 _logError('this test requires the explicit comparison with the ' | 1071 _logError('this test requires the explicit comparison with the ' |
1031 + 'expected result when it runs with run-webkit-tests.'); | 1072 + 'expected result when it runs with run-webkit-tests.'); |
1032 } | 1073 } |
1033 | 1074 |
1034 return new TaskRunner(); | 1075 return new TaskRunner(); |
1035 } | 1076 } |
1036 | 1077 |
1037 }; | 1078 }; |
1038 | 1079 |
1039 })(); | 1080 })(); |
OLD | NEW |