Projects
Mega:23.09
nodejs-expect-dot-js
_service:tar_scm:nodejs-expect-dot-js-0.2.0-Add...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:nodejs-expect-dot-js-0.2.0-Add-actual-expected-property-to-the-thrown-error.patch of Package nodejs-expect-dot-js
From bc56c15ecaad15a48de189bf9de80b4a59ae70c1 Mon Sep 17 00:00:00 2001 From: Gavin Huang <gravof@gmail.com> Date: Tue, 25 Sep 2012 13:13:37 +0800 Subject: [PATCH 06/13] Add 'actual' & 'expected' property to the thrown error --- expect.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/expect.js b/expect.js index ac14ea8..776fc8c 100644 --- a/expect.js +++ b/expect.js @@ -91,12 +91,18 @@ * @api private */ - Assertion.prototype.assert = function (truth, msg, error) { + Assertion.prototype.assert = function (truth, msg, error, expected) { var msg = this.flags.not ? error : msg - , ok = this.flags.not ? !truth : truth; + , ok = this.flags.not ? !truth : truth + , err; if (!ok) { - throw new Error(msg.call(this)); + err = new Error(msg.call(this)); + if (arguments.length > 3) { + err.actual = this.obj + err.expected = expected + } + throw err } this.and = new Assertion(this.obj); @@ -200,7 +206,8 @@ this.assert( obj === this.obj , function(){ return 'expected ' + i(this.obj) + ' to equal ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) }); + , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) } + , obj); return this; }; @@ -214,7 +221,8 @@ this.assert( expect.eql(obj, this.obj) , function(){ return 'expected ' + i(this.obj) + ' to sort of equal ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) }); + , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) } + , obj); return this; }; -- 1.8.2.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2