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 9d61ea42f8136e3381c90f4f1cbec72593dc9952..473b211276dad5735e52dc6d8dcf0e0cb029aafd 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| @@ -98,8 +98,10 @@ window.Audit = (function () { |
| this._expected = null; |
| this._expectedDescription = null; |
| - this._result = true; |
| this._detail = ''; |
| + this._hasArrayLog = false; |
| + |
| + this._result = null; |
| /** |
| * @param {Number} numberOfErrors Number of errors to be printed. |
| @@ -132,10 +134,14 @@ window.Audit = (function () { |
| } |
| _buildResultText () { |
| - if (!this._actualDescription) { |
| - this._actualDescription = |
| - _generateDescription(this._actual, this._options); |
| - } |
| + if (this._result === null) |
| + _throwException('Illegal invocation: the assertion is not finished.'); |
|
Raymond Toy
2016/12/21 18:58:12
What does "not finished" really mean here?
hongchan
2016/12/21 21:30:02
Building result text must be done after the assert
Raymond Toy
2016/12/21 21:57:37
So this is really an error in Audit? Not somethin
|
| + |
| + let actualString = _generateDescription(this._actual, this._options); |
|
Raymond Toy
2016/12/21 18:58:12
Would actualResult be a better name?
hongchan
2016/12/21 21:30:02
This is a stringified result. So I would like to k
Raymond Toy
2016/12/21 21:57:37
I find "String" not really relevant since it's the
hongchan
2016/12/21 22:43:55
Acknowledged.
|
| + |
| + // Use generated text when the description is not provided. |
| + if (!this._actualDescription) |
| + this._actualDescription = actualString; |
| if (!this._expectedDescription) { |
| this._expectedDescription = |
| @@ -168,6 +174,11 @@ window.Audit = (function () { |
| this._detail = this._detail.replace(new RegExp(re, 'g'), |
| _generateDescription(this._options[name])); |
| } |
| + |
| + // If the test is failed, add the actual value at the end. |
|
Raymond Toy
2016/12/21 18:58:12
s/test is/test/
hongchan
2016/12/21 21:30:02
Done.
|
| + if (this._result === false && this._hasArrayLog === false) { |
| + this._detail += ' Got ' + actualString + '.'; |
| + } |
| } |
| _finalize () { |
| @@ -487,6 +498,7 @@ window.Audit = (function () { |
| */ |
| beConstantValueOf () { |
| this._processArguments(arguments); |
| + this._hasArrayLog = true; |
| let passed = true; |
| let passDetail, failDetail; |
| @@ -505,7 +517,7 @@ window.Audit = (function () { |
| } else { |
| let counter = 0; |
| failDetail = 'Expected ${expected} for all values but found ' |
| - + numberOfErrors + ' unexpected values. : '; |
| + + numberOfErrors + ' unexpected values: '; |
| failDetail += '\n\tIndex\tActual'; |
| for (let errorIndex in errors) { |
| failDetail += '\n\t[' + errorIndex + ']' |
| @@ -532,6 +544,7 @@ window.Audit = (function () { |
| */ |
| beEqualToArray () { |
| this._processArguments(arguments); |
| + this._hasArrayLog = true; |
| let passed = true; |
| let passDetail, failDetail; |
| @@ -585,6 +598,7 @@ window.Audit = (function () { |
| */ |
| containValues () { |
| this._processArguments(arguments); |
| + this._hasArrayLog = true; |
| let passed = true; |
| let indexedActual = []; |
| @@ -633,6 +647,7 @@ window.Audit = (function () { |
| */ |
| notGlitch () { |
| this._processArguments(arguments); |
| + this._hasArrayLog = true; |
| let passed = true; |
| let passDetail, failDetail; |
| @@ -676,7 +691,7 @@ window.Audit = (function () { |
| error <= this._options.threshold, |
| '${actual} is ${expected} within an error of ${threshold}.', |
| '${actual} is not close to ${expected} within an error of ' + |
| - '${threshold}'); |
| + '${threshold}.'); |
| } |
| /** |
| @@ -697,6 +712,7 @@ window.Audit = (function () { |
| */ |
| beCloseToArray () { |
| this._processArguments(arguments); |
| + this._hasArrayLog = true; |
| let passed = true; |
| let passDetail, failDetail; |