From d90f152ebcc6f42117cb9d39928b21f8f25805ac Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Fri, 20 Apr 2012 19:35:21 -0400 Subject: [PATCH 1/5] fixed reserved names for old browsers in Assertion --- lib/assertion.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/assertion.js b/lib/assertion.js index 49e6f37..9ad379d 100644 --- a/lib/assertion.js +++ b/lib/assertion.js @@ -581,13 +581,13 @@ Assertion.prototype.a = function (type) { * * expect(Chai).to.be.an.instanceOf(Tea); * - * @name instanceof + * @name instanceOf * @param {Constructor} * @alias instanceOf * @api public */ -Assertion.prototype.instanceof = function (constructor) { +Assertion.prototype.instanceOf = function (constructor) { var name = constructor.name; this.assert( this.obj instanceof constructor @@ -868,7 +868,7 @@ Assertion.prototype.keys = function(keys) { * @api public */ -Assertion.prototype.throw = function (constructor, msg) { +Assertion.prototype.Throw = function (constructor, msg) { new Assertion(this.obj).is.a('function'); var thrown = false; @@ -1010,6 +1010,6 @@ Assertion.prototype.closeTo = function (expected, delta) { ('ownProperty', 'haveOwnProperty') ('above', 'greaterThan') ('below', 'lessThan') -('throw', 'throws') -('throw', 'Throw') // for troublesome browsers -('instanceof', 'instanceOf'); +('Throw', 'throws') +('Throw', 'throw') // for troublesome browsers +('instanceOf', 'instanceof'); From 87e1a54cebd0867890c62e083383abd03e338e28 Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Fri, 20 Apr 2012 19:48:30 -0400 Subject: [PATCH 2/5] fixed: chai.js no longer contains fail() --- lib/error.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/error.js b/lib/error.js index e0f44f8..394433a 100644 --- a/lib/error.js +++ b/lib/error.js @@ -4,8 +4,6 @@ * MIT Licensed */ -var fail = require('./chai').fail; - module.exports = AssertionError; /*! @@ -19,10 +17,9 @@ function AssertionError (options) { this.actual = options.actual; this.expected = options.expected; this.operator = options.operator; - var stackStartFunction = options.stackStartFunction || fail; if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); + Error.captureStackTrace(this, options.stackStartFunction); } } From 1af980779140b4916f7507d652a298e99c7b8550 Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Fri, 20 Apr 2012 19:58:06 -0400 Subject: [PATCH 3/5] fixed reserved names for old browsers in interface/should --- lib/interface/should.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/interface/should.js b/lib/interface/should.js index 7ce3127..86eb3aa 100644 --- a/lib/interface/should.js +++ b/lib/interface/should.js @@ -28,8 +28,8 @@ module.exports = function (chai) { new Assertion(val1).to.equal(val2); }; - should.throw = function (fn, errt, errs) { - new Assertion(fn).to.throw(errt, errs); + should.Throw = function (fn, errt, errs) { + new Assertion(fn).to.Throw(errt, errs); }; should.exist = function (val) { @@ -43,14 +43,17 @@ module.exports = function (chai) { new Assertion(val1).to.not.equal(val2); }; - should.not.throw = function (fn, errt, errs) { - new Assertion(fn).to.not.throw(errt, errs); + should.not.Throw = function (fn, errt, errs) { + new Assertion(fn).to.not.Throw(errt, errs); }; should.not.exist = function (val) { new Assertion(val).to.not.exist; } + should['throw'] = should['Throw']; + should.not['throw'] = should.not['Throw']; + return should; }; }; From 23b9ed37df40ef1a73bf8b8381882e69ddc740db Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Fri, 20 Apr 2012 20:02:00 -0400 Subject: [PATCH 4/5] fixed reserved names for old browsers in interface/assert --- lib/interface/assert.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/interface/assert.js b/lib/interface/assert.js index 0ff1d44..272fac0 100644 --- a/lib/interface/assert.js +++ b/lib/interface/assert.js @@ -221,7 +221,7 @@ module.exports = function (chai) { */ assert.isTrue = function (val, msg) { - new Assertion(val, msg).is.true; + new Assertion(val, msg).is['true']; }; /** @@ -239,7 +239,7 @@ module.exports = function (chai) { */ assert.isFalse = function (val, msg) { - new Assertion(val, msg).is.false; + new Assertion(val, msg).is['false']; }; /** @@ -363,7 +363,7 @@ module.exports = function (chai) { */ assert.isArray = function (val, msg) { - new Assertion(val, msg).to.be.instanceof(Array); + new Assertion(val, msg).to.be.instanceOf(Array); }; /** @@ -459,7 +459,7 @@ module.exports = function (chai) { */ assert.instanceOf = function (val, type, msg) { - new Assertion(val, msg).to.be.instanceof(type); + new Assertion(val, msg).to.be.instanceOf(type); }; /** @@ -548,7 +548,7 @@ module.exports = function (chai) { type = null; } - new Assertion(fn, msg).to.throw(type); + new Assertion(fn, msg).to.Throw(type); }; /** @@ -574,7 +574,7 @@ module.exports = function (chai) { type = null; } - new Assertion(fn, msg).to.not.throw(type); + new Assertion(fn, msg).to.not.Throw(type); }; /** From d1a12f2f9a97b2d7607fe47209dc0bb8183712a9 Mon Sep 17 00:00:00 2001 From: Juliusz Gonera Date: Sat, 21 Apr 2012 00:46:10 -0400 Subject: [PATCH 5/5] browser build --- chai.js | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/chai.js b/chai.js index 9d65f53..557d97e 100644 --- a/chai.js +++ b/chai.js @@ -634,13 +634,13 @@ Assertion.prototype.a = function (type) { * * expect(Chai).to.be.an.instanceOf(Tea); * - * @name instanceof + * @name instanceOf * @param {Constructor} * @alias instanceOf * @api public */ -Assertion.prototype.instanceof = function (constructor) { +Assertion.prototype.instanceOf = function (constructor) { var name = constructor.name; this.assert( this.obj instanceof constructor @@ -921,7 +921,7 @@ Assertion.prototype.keys = function(keys) { * @api public */ -Assertion.prototype.throw = function (constructor, msg) { +Assertion.prototype.Throw = function (constructor, msg) { new Assertion(this.obj).is.a('function'); var thrown = false; @@ -1063,9 +1063,9 @@ Assertion.prototype.closeTo = function (expected, delta) { ('ownProperty', 'haveOwnProperty') ('above', 'greaterThan') ('below', 'lessThan') -('throw', 'throws') -('throw', 'Throw') // for troublesome browsers -('instanceof', 'instanceOf'); +('Throw', 'throws') +('Throw', 'throw') // for troublesome browsers +('instanceOf', 'instanceof'); }); // module: assertion.js @@ -1113,8 +1113,6 @@ require.register("error.js", function(module, exports, require){ * MIT Licensed */ -var fail = require('./chai').fail; - module.exports = AssertionError; /*! @@ -1128,10 +1126,9 @@ function AssertionError (options) { this.actual = options.actual; this.expected = options.expected; this.operator = options.operator; - var stackStartFunction = options.stackStartFunction || fail; if (Error.captureStackTrace) { - Error.captureStackTrace(this, stackStartFunction); + Error.captureStackTrace(this, options.stackStartFunction); } } @@ -1248,7 +1245,10 @@ module.exports = function (chai) { test.assert( exp == test.obj , 'expected ' + test.inspect + ' to equal ' + inspect(exp) - , 'expected ' + test.inspect + ' to not equal ' + inspect(exp)); + , 'expected ' + test.inspect + ' to not equal ' + inspect(exp) + , exp + , act + ); }; /** @@ -1271,7 +1271,10 @@ module.exports = function (chai) { test.assert( exp != test.obj , 'expected ' + test.inspect + ' to equal ' + inspect(exp) - , 'expected ' + test.inspect + ' to not equal ' + inspect(exp)); + , 'expected ' + test.inspect + ' to not equal ' + inspect(exp) + , exp + , act + ); }; /** @@ -1361,7 +1364,7 @@ module.exports = function (chai) { */ assert.isTrue = function (val, msg) { - new Assertion(val, msg).is.true; + new Assertion(val, msg).is['true']; }; /** @@ -1379,7 +1382,7 @@ module.exports = function (chai) { */ assert.isFalse = function (val, msg) { - new Assertion(val, msg).is.false; + new Assertion(val, msg).is['false']; }; /** @@ -1503,7 +1506,7 @@ module.exports = function (chai) { */ assert.isArray = function (val, msg) { - new Assertion(val, msg).to.be.instanceof(Array); + new Assertion(val, msg).to.be.instanceOf(Array); }; /** @@ -1599,7 +1602,7 @@ module.exports = function (chai) { */ assert.instanceOf = function (val, type, msg) { - new Assertion(val, msg).to.be.instanceof(type); + new Assertion(val, msg).to.be.instanceOf(type); }; /** @@ -1688,7 +1691,7 @@ module.exports = function (chai) { type = null; } - new Assertion(fn, msg).to.throw(type); + new Assertion(fn, msg).to.Throw(type); }; /** @@ -1714,7 +1717,7 @@ module.exports = function (chai) { type = null; } - new Assertion(fn, msg).to.not.throw(type); + new Assertion(fn, msg).to.not.Throw(type); }; /** @@ -1813,8 +1816,8 @@ module.exports = function (chai) { new Assertion(val1).to.equal(val2); }; - should.throw = function (fn, errt, errs) { - new Assertion(fn).to.throw(errt, errs); + should.Throw = function (fn, errt, errs) { + new Assertion(fn).to.Throw(errt, errs); }; should.exist = function (val) { @@ -1828,14 +1831,17 @@ module.exports = function (chai) { new Assertion(val1).to.not.equal(val2); }; - should.not.throw = function (fn, errt, errs) { - new Assertion(fn).to.not.throw(errt, errs); + should.not.Throw = function (fn, errt, errs) { + new Assertion(fn).to.not.Throw(errt, errs); }; should.not.exist = function (val) { new Assertion(val).to.not.exist; } + should['throw'] = should['Throw']; + should.not['throw'] = should.not['Throw']; + return should; }; };