Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| index cfadbf891974719211d45a59f01893252273ee59..6c79f572c3aa22c8ef2d174c7581578feebe92ec 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| @@ -541,6 +541,50 @@ window.Audit = (function () { |
| } |
| /** |
| + * Check if |actual| array is not filled with a constant |expected| value. |
| + * |
| + * @example |
| + * should([1, 0, 1]).notBeConstantValueOf(1); |
| + * should([0, 0, 0]).notBeConstantValueOf(0); |
| + * |
| + * @result |
| + * "PASS [1,0,1] is not constantly 1 (contains 1 different value)." |
| + * "FAIL X [0,0,0] should have contain at least one value different |
| + * from 0." |
| + */ |
| + notBeConstantValueOf () { |
| + this._processArguments(arguments); |
| + this._printActualForFailure = false; |
| + |
| + let passed = true; |
| + let passDetail; |
| + let failDetail; |
| + let differences = {}; |
| + |
| + for (let index in this._actual) { |
| + if (this._actual[index] !== this._expected) |
| + differences[index] = this._actual[index]; |
| + } |
| + |
| + let numberOfDifferences = Object.keys(differences).length; |
| + passed = numberOfDifferences > 0; |
| + |
| + if (passed) { |
| + let valueString = { |
| + noun: numberOfDifferences > 1 ? 'values' : 'value', |
|
Raymond Toy
2017/01/06 22:03:43
Nit: Since you have "values" and "differs", you pr
hongchan
2017/01/06 22:08:55
Done. Also removed the 'differs' part since it's n
|
| + verb: numberOfDifferences > 1 ? 'differ' : 'differs' |
| + }; |
| + passDetail = '${actual} is not constantly ${expected} (contains ' + |
| + numberOfDifferences + ' different ' + valueString.noun + ').'; |
| + } else { |
| + failDetail = '${actual} should have contain at least one value ' + |
| + 'different from ${expected}.'; |
| + } |
| + |
| + return this._assert(passed, passDetail, failDetail); |
| + } |
| + |
| + /** |
| * Check if |actual| array is identical to |expected| array element-wise. |
| * |
| * @example |