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 177484af53389b6e39e49ccb183174e715c552e7..e93e4e2b4770204f3f007207b9a47cbc97f25bc5 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/audit.js |
| @@ -152,20 +152,29 @@ window.Audit = (function () { |
| } |
| // For the assertion with a single operand. |
| - this._detail = this._detail.replace('${actual}', this._actualDescription); |
| + this._detail = this._detail.replace( |
| + /\$\{actual\}/g, this._actualDescription); |
| // If there is a second operand (i.e. expected value), we have to build |
| // the string for it as well. |
| - if (this._expected) { |
| + if (this._expected !== null) { |
| this._detail = this._detail.replace( |
| - '${expected}', this._expectedDescription); |
| + /\$\{expected\}/g, this._expectedDescription); |
| } |
| // If there is any property in |_options|, replace the property name |
| // with the value. |
| for (let name in this._options) { |
| - this._detail = this._detail.replace( |
| - '${' + name + '}', |
| + if (name === 'numberOfErrors' |
|
Raymond Toy
2016/12/08 00:06:02
Why do you have to do this?
hongchan
2016/12/08 17:52:12
Because we don't want to print out 'numberOfErrors
|
| + || name === 'numberOfArrayElements' |
| + || name === 'verbose') { |
| + continue; |
| + } |
| + |
| + // The RegExp key string contains special character. Take care of it. |
| + let re = '\$\{' + name + '\}'; |
| + re = re.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'); |
| + this._detail = this._detail.replace(new RegExp(re, 'g'), |
| _generateDescription(this._options[name])); |
| } |
| } |
| @@ -647,11 +656,11 @@ window.Audit = (function () { |
| * |threshold|. |
| * |
| * @example |
| - * should(2.3).beCloseTo(2, 0.3); |
| + * should(2.3).beCloseTo(2, { threshold: 0.3 }); |
| * |
| * @result |
| * "PASS 2.3 is 2 within an error of 0.3." |
| - * |
| + * @param {Object} options Options for assertion. |
| * @param {Number} options.threshold Threshold value for the comparison. |
| */ |
| beCloseTo () { |
| @@ -661,9 +670,9 @@ window.Audit = (function () { |
| let error = Math.abs(this._actual - this._expected) / absExpected; |
| return this._assert( |
| - error < this._options.threshold, |
| - '${actual} is ${expected} within an error of ${threshold}', |
| - '${actual} is not ${expected} within a error of ${threshold}: ' + |
| + error <= this._options.threshold, |
| + '${actual} is ${expected} within an error of ${threshold}.', |
| + '${actual} is not ${expected} within an error of ${threshold}: ' + |
| '${actual} with error of ${threshold}.'); |
| } |
| @@ -941,14 +950,14 @@ window.Audit = (function () { |
| // the specified one. |
| if (arguments.length > 0) { |
| this._taskSequence = []; |
| - for (let i = 0; arguments.length; i++) { |
| + for (let i = 0; i < arguments.length; i++) { |
| let taskLabel = arguments[i]; |
| if (!this._tasks.hasOwnProperty(taskLabel)) { |
| _throwException('Audit.run:: undefined task.'); |
| } else if (this._taskSequence.includes(taskLabel)) { |
| _throwException('Audit.run:: duplicate task request.'); |
| } else { |
| - this._taskSequence.push[taskLabel]; |
| + this._taskSequence.push(taskLabel); |
| } |
| } |
| } |