Skip to content

Commit

Permalink
make build
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 7, 2015
1 parent 784558b commit f14d997
Showing 1 changed file with 176 additions and 127 deletions.
303 changes: 176 additions & 127 deletions chai.js
Expand Up @@ -138,120 +138,6 @@ require.define = function (name, exports) {
exports: exports
};
};
require.register("chaijs~assertion-error@1.0.0", function (exports, module) {
/*!
* assertion-error
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
* MIT Licensed
*/

/*!
* Return a function that will copy properties from
* one object to another excluding any originally
* listed. Returned function will create a new `{}`.
*
* @param {String} excluded properties ...
* @return {Function}
*/

function exclude () {
var excludes = [].slice.call(arguments);

function excludeProps (res, obj) {
Object.keys(obj).forEach(function (key) {
if (!~excludes.indexOf(key)) res[key] = obj[key];
});
}

return function extendExclude () {
var args = [].slice.call(arguments)
, i = 0
, res = {};

for (; i < args.length; i++) {
excludeProps(res, args[i]);
}

return res;
};
};

/*!
* Primary Exports
*/

module.exports = AssertionError;

/**
* ### AssertionError
*
* An extension of the JavaScript `Error` constructor for
* assertion and validation scenarios.
*
* @param {String} message
* @param {Object} properties to include (optional)
* @param {callee} start stack function (optional)
*/

function AssertionError (message, _props, ssf) {
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
, props = extend(_props || {});

// default values
this.message = message || 'Unspecified AssertionError';
this.showDiff = false;

// copy from properties
for (var key in props) {
this[key] = props[key];
}

// capture stack trace
ssf = ssf || arguments.callee;
if (ssf && Error.captureStackTrace) {
Error.captureStackTrace(this, ssf);
}
}

/*!
* Inherit from Error.prototype
*/

AssertionError.prototype = Object.create(Error.prototype);

/*!
* Statically set name
*/

AssertionError.prototype.name = 'AssertionError';

/*!
* Ensure correct constructor
*/

AssertionError.prototype.constructor = AssertionError;

/**
* Allow errors to be converted to JSON for static transfer.
*
* @param {Boolean} include stack (default: `true`)
* @return {Object} object that can be `JSON.stringify`
*/

AssertionError.prototype.toJSON = function (stack) {
var extend = exclude('constructor', 'toJSON', 'stack')
, props = extend({ name: this.name }, this);

// include stack if exists and not turned off
if (false !== stack && this.stack) {
props.stack = this.stack;
}

return props;
};

});

require.register("chaijs~type-detect@0.1.1", function (exports, module) {
/*!
* type-detect
Expand Down Expand Up @@ -659,6 +545,120 @@ function objectEqual(a, b, m) {

});

require.register("chaijs~assertion-error@1.0.0", function (exports, module) {
/*!
* assertion-error
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
* MIT Licensed
*/

/*!
* Return a function that will copy properties from
* one object to another excluding any originally
* listed. Returned function will create a new `{}`.
*
* @param {String} excluded properties ...
* @return {Function}
*/

function exclude () {
var excludes = [].slice.call(arguments);

function excludeProps (res, obj) {
Object.keys(obj).forEach(function (key) {
if (!~excludes.indexOf(key)) res[key] = obj[key];
});
}

return function extendExclude () {
var args = [].slice.call(arguments)
, i = 0
, res = {};

for (; i < args.length; i++) {
excludeProps(res, args[i]);
}

return res;
};
};

/*!
* Primary Exports
*/

module.exports = AssertionError;

/**
* ### AssertionError
*
* An extension of the JavaScript `Error` constructor for
* assertion and validation scenarios.
*
* @param {String} message
* @param {Object} properties to include (optional)
* @param {callee} start stack function (optional)
*/

function AssertionError (message, _props, ssf) {
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
, props = extend(_props || {});

// default values
this.message = message || 'Unspecified AssertionError';
this.showDiff = false;

// copy from properties
for (var key in props) {
this[key] = props[key];
}

// capture stack trace
ssf = ssf || arguments.callee;
if (ssf && Error.captureStackTrace) {
Error.captureStackTrace(this, ssf);
}
}

/*!
* Inherit from Error.prototype
*/

AssertionError.prototype = Object.create(Error.prototype);

/*!
* Statically set name
*/

AssertionError.prototype.name = 'AssertionError';

/*!
* Ensure correct constructor
*/

AssertionError.prototype.constructor = AssertionError;

/**
* Allow errors to be converted to JSON for static transfer.
*
* @param {Boolean} include stack (default: `true`)
* @return {Object} object that can be `JSON.stringify`
*/

AssertionError.prototype.toJSON = function (stack) {
var extend = exclude('constructor', 'toJSON', 'stack')
, props = extend({ name: this.name }, this);

// include stack if exists and not turned off
if (false !== stack && this.stack) {
props.stack = this.stack;
}

return props;
};

});

require.register("chai", function (exports, module) {
module.exports = require('chai/lib/chai.js');

Expand Down Expand Up @@ -1051,7 +1051,7 @@ module.exports = function (chai, _) {
* ### .any
*
* Sets the `any` flag, (opposite of the `all` flag)
* later used in the `keys` assertion.
* later used in the `keys` assertion.
*
* expect(foo).to.have.any.keys('bar', 'baz');
*
Expand All @@ -1068,7 +1068,7 @@ module.exports = function (chai, _) {
/**
* ### .all
*
* Sets the `all` flag (opposite of the `any` flag)
* Sets the `all` flag (opposite of the `any` flag)
* later used by the `keys` assertion.
*
* expect(foo).to.have.all.keys('bar', 'baz');
Expand Down Expand Up @@ -1725,7 +1725,7 @@ module.exports = function (chai, _) {
* green: { tea: 'matcha' }
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
* };
*
*
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
Expand Down Expand Up @@ -1846,6 +1846,55 @@ module.exports = function (chai, _) {
Assertion.addMethod('ownProperty', assertOwnProperty);
Assertion.addMethod('haveOwnProperty', assertOwnProperty);

/**
* ### .ownPropertyDescriptor(name[, descriptor[, message]])
*
* Asserts that the target has an own property descriptor `name`, that optionally matches `descriptor`.
*
* expect('test').to.have.ownPropertyDescriptor('length');
* expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
* expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
* expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
* expect('test').ownPropertyDescriptor('length').to.have.keys('value');
*
* @name ownPropertyDescriptor
* @alias haveOwnPropertyDescriptor
* @param {String} name
* @param {Object} descriptor _optional_
* @param {String} message _optional_
* @api public
*/

function assertOwnPropertyDescriptor (name, descriptor, msg) {
if (typeof descriptor === 'string') {
msg = descriptor;
descriptor = null;
}
if (msg) flag(this, 'message', msg);
var obj = flag(this, 'object');
var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
if (actualDescriptor && descriptor) {
this.assert(
_.eql(descriptor, actualDescriptor)
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor)
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor)
, descriptor
, actualDescriptor
, true
);
} else {
this.assert(
actualDescriptor
, 'expected #{this} to have an own property descriptor for ' + _.inspect(name)
, 'expected #{this} to not have an own property descriptor for ' + _.inspect(name)
);
}
flag(this, 'object', actualDescriptor);
}

Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);

/**
* ### .length(value)
*
Expand Down Expand Up @@ -1947,30 +1996,30 @@ module.exports = function (chai, _) {
* ### .keys(key1, [key2], [...])
*
* Asserts that the target contains any or all of the passed-in keys.
* Use in combination with `any`, `all`, `contains`, or `have` will affect
* Use in combination with `any`, `all`, `contains`, or `have` will affect
* what will pass.
*
* When used in conjunction with `any`, at least one key that is passed
* in must exist in the target object. This is regardless whether or not
*
* When used in conjunction with `any`, at least one key that is passed
* in must exist in the target object. This is regardless whether or not
* the `have` or `contain` qualifiers are used. Note, either `any` or `all`
* should be used in the assertion. If neither are used, the assertion is
* defaulted to `all`.
*
* When both `all` and `contain` are used, the target object must have at
*
* When both `all` and `contain` are used, the target object must have at
* least all of the passed-in keys but may have more keys not listed.
*
*
* When both `all` and `have` are used, the target object must both contain
* all of the passed-in keys AND the number of keys in the target object must
* match the number of keys passed in (in other words, a target object must
* match the number of keys passed in (in other words, a target object must
* have all and only all of the passed-in keys).
*
*
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
* expect({ foo: 1, bar: 2 }).to.contain.any.keys('bar', 'baz');
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
* expect({ foo: 1, bar: 2 }).to.contain.any.keys({'foo': 6});
* expect({ foo: 1, bar: 2 }).to.have.all.keys(['bar', 'foo']);
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo', 7});
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo': 7});
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
*
Expand Down

0 comments on commit f14d997

Please sign in to comment.