Skip to content

Commit

Permalink
added strict equal + negatives and ifError
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalparadox committed Dec 24, 2011
1 parent 6cb347e commit b1de998
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions lib/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/*!
* Module dependencies.
*/
var Assertion = require('../assertion');
var Assertion = require('../assertion')
, inspect = require('../utils/inspect')

/*!
* Module export.
Expand Down Expand Up @@ -64,7 +65,12 @@ assert.ok = function (val, msg) {
*/

assert.equal = function (act, exp, msg) {
new Assertion(act, msg).to.equal(exp);
var test = new Assertion(act, msg);

test.assert(
exp == test.obj
, 'expected ' + this.inspect + ' to equal ' + inspect(exp)
, 'expected ' + this.inspect + ' to not equal ' + inspect(exp));
};

/**
Expand All @@ -82,6 +88,19 @@ assert.equal = function (act, exp, msg) {
*/

assert.notEqual = function (act, exp, msg) {
var test = new Assertion(act, msg);

test.assert(
exp != test.obj
, 'expected ' + this.inspect + ' to equal ' + inspect(exp)
, 'expected ' + this.inspect + ' to not equal ' + inspect(exp));
};

assert.strictEqual = function (act, exp, msg) {
new Assertion(act, msg).to.equal(exp);
};

assert.notStrictEqual = function (act, exp, msg) {
new Assertion(act, msg).to.not.equal(exp);
};

Expand Down Expand Up @@ -458,6 +477,10 @@ assert.doesNotThrow = function (fn, type, msg) {
new Assertion(fn, msg).to.not.throw(type);
};

assert.ifError = function (val, msg) {
new Assertion(val, msg).to.not.be.ok;
};

/*!
* Aliases.
*/
Expand Down

0 comments on commit b1de998

Please sign in to comment.