mirror of
https://github.com/chaijs/chai
synced 2024-11-15 08:17:14 +00:00
Fixing up AssertionError
inheritance.
* Use `Object.create` instead of `__proto__` for inheritance. * Don't forget to set `AssertionError.prototype.constructor`. * Put `name` on `AssertionError.prototype`, not on each instance.
This commit is contained in:
parent
e7d89e24dd
commit
272fcf5a3c
2 changed files with 6 additions and 4 deletions
|
@ -8,7 +8,6 @@ module.exports = AssertionError;
|
|||
|
||||
function AssertionError (options) {
|
||||
options = options || {};
|
||||
this.name = 'AssertionError';
|
||||
this.message = options.message;
|
||||
this.actual = options.actual;
|
||||
this.expected = options.expected;
|
||||
|
@ -20,7 +19,9 @@ function AssertionError (options) {
|
|||
}
|
||||
}
|
||||
|
||||
AssertionError.prototype.__proto__ = Error.prototype;
|
||||
AssertionError.prototype = Object.create(Error.prototype);
|
||||
AssertionError.prototype.name = 'AssertionError';
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
|
||||
AssertionError.prototype.toString = function() {
|
||||
return this.message;
|
||||
|
|
|
@ -35,7 +35,6 @@ module.exports = AssertionError;
|
|||
|
||||
function AssertionError (options) {
|
||||
options = options || {};
|
||||
this.name = 'AssertionError';
|
||||
this.message = options.message;
|
||||
this.actual = options.actual;
|
||||
this.expected = options.expected;
|
||||
|
@ -80,7 +79,9 @@ function AssertionError (options) {
|
|||
* Inherit from Error
|
||||
*/
|
||||
|
||||
AssertionError.prototype.__proto__ = Error.prototype;
|
||||
AssertionError.prototype = Object.create(Error.prototype);
|
||||
AssertionError.prototype.name = 'AssertionError';
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
|
||||
/**
|
||||
* # toString()
|
||||
|
|
Loading…
Reference in a new issue