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..13da1608b3718ed5c39676eb3ae8d4e6c676e2a5 100644 |
--- a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
@@ -541,6 +541,48 @@ 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] contains values that differ from the constant 1." |
Raymond Toy
2017/01/06 18:50:12
This doesn't seem to match what the code is produc
hongchan
2017/01/06 19:14:42
Done.
|
+ * "FAIL [0,0,0] contains only the constant 0." |
+ */ |
+ notBeConstantValueOf () { |
+ this._processArguments(arguments); |
+ this._printActualForFailure = false; |
+ |
+ let passed = true; |
+ let passDetail, failDetail; |
Raymond Toy
2017/01/06 18:50:12
Should this be two separate lets? Couldn't find a
hongchan
2017/01/06 19:14:42
You are correct. Should I fix this instance only?
|
+ let differences = {}; |
Raymond Toy
2017/01/06 18:50:12
Would it be better if differences were an (empty)
hongchan
2017/01/06 19:14:42
Not sure. I thought you might want to print out th
|
+ |
+ 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', |
+ verb: numberOfDifferences > 1 ? 'differ' : 'differs' |
+ }; |
+ passDetail = '${actual} contains ' + numberOfDifferences + ' ' + |
+ valueString.noun + ' that ' + valueString.verb + ' from the ' + |
+ 'constant ${expected}.'; |
+ } else { |
+ failDetail = '${actual} contains only the constant ${expected}.'; |
Raymond Toy
2017/01/06 18:50:12
It might be better, maybe, to say "${actual} shoul
hongchan
2017/01/06 19:14:42
Thanks, your phrasing is much better. Done.
|
+ } |
+ |
+ return this._assert(passed, passDetail, failDetail); |
+ } |
+ |
+ /** |
* Check if |actual| array is identical to |expected| array element-wise. |
* |
* @example |