Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/resources/audio-testing.js |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/audio-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/audio-testing.js |
| index 33f8ac54a81e09d46ec842f124a898b3e0671b67..13220d1674b9410c2f4cfaf0547f2b858d6e0b80 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/audio-testing.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/audio-testing.js |
| @@ -527,8 +527,9 @@ var Should = (function () { |
| return this._success; |
| } |
| - // Check if |target| is close to |value| using the given relative error |threshold|. |
| - // |value| should not be zero, but no check is made for that. |
| + // Check if |target| is close to |value| using the given relative error |threshold|. |value| |
| + // should not be zero, but no check is made for that. The |target| value is printed to |
| + // precision |precision|, with |precision| defaulting to 7. |
| // |
| // Example: |
| // Should("One", 1.001).beCloseTo(1, .1); |
| @@ -536,16 +537,21 @@ var Should = (function () { |
| // Result: |
| // "PASS One is 1 within a relative error of 0.1." |
| // "FAIL One is not 1 within a relative error of 0.1: 2" |
| - ShouldModel.prototype.beCloseTo = function (value, relativeErrorThreshold) { |
| + ShouldModel.prototype.beCloseTo = function (value, relativeErrorThreshold, precision) { |
| var type = typeof value; |
|
hongchan
2015/09/30 22:14:18
Let's remove this line and...
Raymond Toy
2015/09/30 22:30:18
I was following the other parts of the code....
hongchan
2015/09/30 22:47:58
Ha, you're right. Let's leave it as it is for now.
|
| this._assert(type === 'number', 'value should be number for'); |
|
hongchan
2015/09/30 22:14:18
change this to: typeof value === 'number'
hongchan
2015/09/30 22:47:59
Please disregard this comment.
|
| var relativeError = Math.abs(this.target - value) / Math.abs(value); |
| if (relativeError <= relativeErrorThreshold) { |
| - this._testPassed("is " + value + " within a relative error of " + relativeErrorThreshold); |
| + this._testPassed("is " + value.toPrecision(precision) + |
| + " within a relative error of " + relativeErrorThreshold); |
| } else { |
| - this._testFailed("is not " + value + " within a relative error of " + relativeErrorThreshold |
| - + ": " + this.target); |
| + // Include actual relative error so the failed test case can be updated with the actual |
| + // relative error, if appropriate. |
| + this._testFailed("is not " + value.toPrecision(precision) + |
| + " within a relative error of " + relativeErrorThreshold + |
| + ": " + this.target + " with relative error " + relativeError |
| + ); |
| } |
| return this._success; |
| } |