Commit a2f8f05c authored by Sindre Sorhus's avatar Sindre Sorhus

Upgrade and minify Chai. Upgrade Ember.

parent 17bcd4db
......@@ -3,7 +3,7 @@ require.config({
baseUrl: 'js/',
paths: {
jquery: '../../../assets/jquery.min',
ember: 'lib/ember-0.9.7.1.min',
ember: 'lib/ember-0.9.8.1.min',
text: 'lib/require/text',
mocha: 'lib/mocha',
chai: 'lib/chai'
......
!function (name, definition) {
if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
else this[name] = definition();
}('chai', function () {
// CommonJS require()
function require(p){
var path = require.resolve(p)
, mod = require.modules[path];
if (!mod) throw new Error('failed to require "' + p + '"');
if (!mod.exports) {
mod.exports = {};
mod.call(mod.exports, mod, mod.exports, require.relative(path));
}
return mod.exports;
}
require.modules = {};
require.resolve = function (path){
var orig = path
, reg = path + '.js'
, index = path + '/index.js';
return require.modules[reg] && reg
|| require.modules[index] && index
|| orig;
};
require.register = function (path, fn){
require.modules[path] = fn;
};
require.relative = function (parent) {
return function(p){
if ('.' != p[0]) return require(p);
var path = parent.split('/')
, segs = p.split('/');
path.pop();
for (var i = 0; i < segs.length; i++) {
var seg = segs[i];
if ('..' == seg) path.pop();
else if ('.' != seg) path.push(seg);
}
return require(path.join('/'));
};
};
require.register("assertion.js", function(module, exports, require){
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*
* Primarily a refactor of: should.js
* https://github.com/visionmedia/should.js
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* ### BDD Style Introduction
*
* The BDD style is exposed through `expect` or `should` interfaces. In both
* scenarios, you chain together natural language assertions.
*
* // expect
* var expect = require('chai').expect;
* expect(foo).to.equal('bar');
*
* // should
* var should = require('chai').should();
* foo.should.equal('bar');
*
* #### Differences
*
* The `expect` interface provides a function as a starting point for chaining
* your language assertions. It works on node.js and in all browsers.
*
* The `should` interface extends `Object.prototype` to provide a single getter as
* the starting point for your language assertions. It works on node.js and in
* all browsers except Internet Explorer.
*
* #### Configuration
*
* By default, Chai does not show stack traces upon an AssertionError. This can
* be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
*
* var chai = require('chai');
* chai.Assertion.includeStack = true; // defaults to false
*/
/*!
* Module dependencies.
*/
var AssertionError = require('./error')
, eql = require('./utils/eql')
, toString = Object.prototype.toString
, inspect = require('./utils/inspect');
/*!
* Module export.
*/
module.exports = Assertion;
/*!
* # Assertion Constructor
*
* Creates object for chaining.
*
* @api private
*/
function Assertion (obj, msg, stack) {
this.ssfi = stack || arguments.callee;
this.obj = obj;
this.msg = msg;
}
/*!
* ## Assertion.includeStack
* , toString = Object.prototype.toString
*
* User configurable property, influences whether stack trace
* is included in Assertion error message. Default of false
* suppresses stack trace in the error message
*
* Assertion.includeStack = true; // enable stack on error
*
* @api public
*/
Assertion.includeStack = false;
/*!
* # .assert(expression, message, negateMessage)
*
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
*
* @name assert
* @param {Philosophical} expression to be tested
* @param {String} message to display if fails
* @param {String} negatedMessage to display if negated expression fails
* @api private
*/
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, actual) {
actual = actual || this.obj;
var msg = (this.negate ? negateMsg : msg)
, ok = this.negate ? !expr : expr;
if (!ok) {
throw new AssertionError({
message: this.msg ? this.msg + ': ' + msg : msg // include custom message if available
, actual: actual
, expected: expected
, stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi
});
}
};
/*!
* # inspect
*
* Returns the current object stringified.
*
* @name inspect
* @api private
*/
Object.defineProperty(Assertion.prototype, 'inspect',
{ get: function () {
return inspect(this.obj);
}
, configurable: true
});
/**
* # to
*
* Language chain.
*
* @name to
* @api public
*/
Object.defineProperty(Assertion.prototype, 'to',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # be
*
* Language chain.
*
* @name be
* @api public
*/
Object.defineProperty(Assertion.prototype, 'be',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # been
*
* Language chain. Also tests `tense` to past for addon
* modules that use the tense feature.
*
* @name been
* @api public
*/
Object.defineProperty(Assertion.prototype, 'been',
{ get: function () {
this.tense = 'past';
return this;
}
, configurable: true
});
/**
* # an
*
* Language chain.
*
* @name an
* @api public
*/
Object.defineProperty(Assertion.prototype, 'an',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # is
*
* Language chain.
*
* @name is
* @api public
*/
Object.defineProperty(Assertion.prototype, 'is',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # and
*
* Language chain.
*
* @name and
* @api public
*/
Object.defineProperty(Assertion.prototype, 'and',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # have
*
* Language chain.
*
* @name have
* @api public
*/
Object.defineProperty(Assertion.prototype, 'have',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # with
*
* Language chain.
*
* @name with
* @api public
*/
Object.defineProperty(Assertion.prototype, 'with',
{ get: function () {
return this;
}
, configurable: true
});
/**
* # .not
*
* Negates any of assertions following in the chain.
*
* @name not
* @api public
*/
Object.defineProperty(Assertion.prototype, 'not',
{ get: function () {
this.negate = true;
return this;
}
, configurable: true
});
/**
* # .ok
*
* Assert object truthiness.
*
* expect('everthing').to.be.ok;
* expect(false).to.not.be.ok;
* expect(undefined).to.not.be.ok;
* expect(null).to.not.be.ok;
*
* @name ok
* @api public
*/
Object.defineProperty(Assertion.prototype, 'ok',
{ get: function () {
this.assert(
this.obj
, 'expected ' + this.inspect + ' to be truthy'
, 'expected ' + this.inspect + ' to be falsy');
return this;
}
, configurable: true
});
/**
* # .true
*
* Assert object is true
*
* @name true
* @api public
*/
Object.defineProperty(Assertion.prototype, 'true',
{ get: function () {
this.assert(
true === this.obj
, 'expected ' + this.inspect + ' to be true'
, 'expected ' + this.inspect + ' to be false'
, this.negate ? false : true
);
return this;
}
, configurable: true
});
/**
* # .false
*
* Assert object is false
*
* @name false
* @api public
*/
Object.defineProperty(Assertion.prototype, 'false',
{ get: function () {
this.assert(
false === this.obj
, 'expected ' + this.inspect + ' to be false'
, 'expected ' + this.inspect + ' to be true'
, this.negate ? true : false
);
return this;
}
, configurable: true
});
/**
* # .exist
*
* Assert object exists (null).
*
* var foo = 'hi'
* , bar;
* expect(foo).to.exist;
* expect(bar).to.not.exist;
*
* @name exist
* @api public
*/
Object.defineProperty(Assertion.prototype, 'exist',
{ get: function () {
this.assert(
null != this.obj
, 'expected ' + this.inspect + ' to exist'
, 'expected ' + this.inspect + ' to not exist'
);
return this;
}
, configurable: true
});
/**
* # .empty
*
* Assert object's length to be 0.
*
* expect([]).to.be.empty;
*
* @name empty
* @api public
*/
Object.defineProperty(Assertion.prototype, 'empty',
{ get: function () {
var expected = this.obj;
if (Array.isArray(this.obj)) {
expected = this.obj.length;
} else if (typeof this.obj === 'object') {
expected = Object.keys(this.obj).length;
}
this.assert(
!expected
, 'expected ' + this.inspect + ' to be empty'
, 'expected ' + this.inspect + ' not to be empty');
return this;
}
, configurable: true
});
/**
* # .arguments
*
* Assert object is an instanceof arguments.
*
* function test () {
* expect(arguments).to.be.arguments;
* }
*
* @name arguments
* @api public
*/
Object.defineProperty(Assertion.prototype, 'arguments',
{ get: function () {
this.assert(
'[object Arguments]' == Object.prototype.toString.call(this.obj)
, 'expected ' + this.inspect + ' to be arguments'
, 'expected ' + this.inspect + ' to not be arguments'
, '[object Arguments]'
, Object.prototype.toString.call(this.obj)
);
return this;
}
, configurable: true
});
/**
* # .equal(value)
*
* Assert strict equality.
*
* expect('hello').to.equal('hello');
*
* @name equal
* @param {*} value
* @api public
*/
Assertion.prototype.equal = function (val) {
this.assert(
val === this.obj
, 'expected ' + this.inspect + ' to equal ' + inspect(val)
, 'expected ' + this.inspect + ' to not equal ' + inspect(val)
, val );
return this;
};
/**
* # .eql(value)
*
* Assert deep equality.
*
* expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
*
* @name eql
* @param {*} value
* @api public
*/
Assertion.prototype.eql = function (obj) {
this.assert(
eql(obj, this.obj)
, 'expected ' + this.inspect + ' to equal ' + inspect(obj)
, 'expected ' + this.inspect + ' to not equal ' + inspect(obj)
, obj );
return this;
};
/**
* # .above(value)
*
* Assert greater than `value`.
*
* expect(10).to.be.above(5);
*
* @name above
* @param {Number} value
* @api public
*/
Assertion.prototype.above = function (val) {
this.assert(
this.obj > val
, 'expected ' + this.inspect + ' to be above ' + val
, 'expected ' + this.inspect + ' to be below ' + val);
return this;
};
/**
* # .below(value)
*
* Assert less than `value`.
*
* expect(5).to.be.below(10);
*
* @name below
* @param {Number} value
* @api public
*/
Assertion.prototype.below = function (val) {
this.assert(
this.obj < val
, 'expected ' + this.inspect + ' to be below ' + val
, 'expected ' + this.inspect + ' to be above ' + val);
return this;
};
/**
* # .within(start, finish)
*
* Assert that a number is within a range.
*
* expect(7).to.be.within(5,10);
*
* @name within
* @param {Number} start lowerbound inclusive
* @param {Number} finish upperbound inclusive
* @api public
*/
Assertion.prototype.within = function (start, finish) {
var range = start + '..' + finish;
this.assert(
this.obj >= start && this.obj <= finish
, 'expected ' + this.inspect + ' to be within ' + range
, 'expected ' + this.inspect + ' to not be within ' + range);
return this;
};
/**
* # .a(type)
*
* Assert typeof.
*
* expect('test').to.be.a('string');
*
* @name a
* @param {String} type
* @api public
*/
Assertion.prototype.a = function (type) {
var klass = type.charAt(0).toUpperCase() + type.slice(1);
this.assert(
'[object ' + klass + ']' === toString.call(this.obj)
, 'expected ' + this.inspect + ' to be a ' + type
, 'expected ' + this.inspect + ' not to be a ' + type
, '[object ' + klass + ']'
, toString.call(this.obj)
);
return this;
};
/**
* # .instanceof(constructor)
*
* Assert instanceof.
*
* var Tea = function (name) { this.name = name; }
* , Chai = new Tea('chai');
*
* expect(Chai).to.be.an.instanceOf(Tea);
*
* @name instanceof
* @param {Constructor}
* @alias instanceOf
* @api public
*/
Assertion.prototype.instanceof = function (constructor) {
var name = constructor.name;
this.assert(
this.obj instanceof constructor
, 'expected ' + this.inspect + ' to be an instance of ' + name
, 'expected ' + this.inspect + ' to not be an instance of ' + name);
return this;
};
/**
* # .property(name, [value])
*
* Assert that property of `name` exists, optionally with `value`.
*
* var obj = { foo: 'bar' }
* expect(obj).to.have.property('foo');
* expect(obj).to.have.property('foo', 'bar');
* expect(obj).to.have.property('foo').to.be.a('string');
*
* @name property
* @param {String} name
* @param {*} value (optional)
* @returns value of property for chaining
* @api public
*/
Assertion.prototype.property = function (name, val) {
if (this.negate && undefined !== val) {
if (undefined === this.obj[name]) {
throw new Error(this.inspect + ' has no property ' + inspect(name));
}
} else {
this.assert(
undefined !== this.obj[name]
, 'expected ' + this.inspect + ' to have a property ' + inspect(name)
, 'expected ' + this.inspect + ' to not have property ' + inspect(name));
}
if (undefined !== val) {
this.assert(
val === this.obj[name]
, 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +
inspect(val) + ', but got ' + inspect(this.obj[name])
, 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val)
, val
, this.obj[val]
);
}
this.obj = this.obj[name];
return this;
};
/**
* # .ownProperty(name)
*
* Assert that has own property by `name`.
*
* expect('test').to.have.ownProperty('length');
*
* @name ownProperty
* @alias haveOwnProperty
* @param {String} name
* @api public
*/
Assertion.prototype.ownProperty = function (name) {
this.assert(
this.obj.hasOwnProperty(name)
, 'expected ' + this.inspect + ' to have own property ' + inspect(name)
, 'expected ' + this.inspect + ' to not have own property ' + inspect(name));
return this;
};
/**
* # .length(val)
*
* Assert that object has expected length.
*
* expect([1,2,3]).to.have.length(3);
* expect('foobar').to.have.length(6);
*
* @name length
* @alias lengthOf
* @param {Number} length
* @api public
*/
Assertion.prototype.length = function (n) {
new Assertion(this.obj).to.have.property('length');
var len = this.obj.length;
this.assert(
len == n
, 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len
, 'expected ' + this.inspect + ' to not have a length of ' + len
, n
, len
);
return this;
};
/**
* # .match(regexp)
*
* Assert that matches regular expression.
*
* expect('foobar').to.match(/^foo/);
*
* @name match
* @param {RegExp} RegularExpression
* @api public
*/
Assertion.prototype.match = function (re) {
this.assert(
re.exec(this.obj)
, 'expected ' + this.inspect + ' to match ' + re
, 'expected ' + this.inspect + ' not to match ' + re);
return this;
};
/**
* # .include(obj)
*
* Assert the inclusion of an object in an Array or substring in string.
*
* expect([1,2,3]).to.include(2);
*
* @name include
* @param {Object|String|Number} obj
* @api public
*/
Assertion.prototype.include = function (obj) {
this.assert(
~this.obj.indexOf(obj)
, 'expected ' + this.inspect + ' to include ' + inspect(obj)
, 'expected ' + this.inspect + ' to not include ' + inspect(obj));
return this;
};
/**
* # .string(string)
*
* Assert inclusion of string in string.
*
* expect('foobar').to.have.string('bar');
*
* @name string
* @param {String} string
* @api public
*/
Assertion.prototype.string = function (str) {
new Assertion(this.obj).is.a('string');
this.assert(
~this.obj.indexOf(str)
, 'expected ' + this.inspect + ' to contain ' + inspect(str)
, 'expected ' + this.inspect + ' to not contain ' + inspect(str));
return this;
};
/**
* # contain
*
* Toggles the `contain` flag for the `keys` assertion.
*
* @name contain
* @api public
*/
Object.defineProperty(Assertion.prototype, 'contain',
{ get: function () {
this.contains = true;
return this;
},
configurable: true
});
/**
* # .keys(key1, [key2], [...])
*
* Assert exact keys or the inclusing of keys using the `contain` modifier.
*
* expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
*
* @name keys
* @alias key
* @param {String|Array} Keys
* @api public
*/
Assertion.prototype.keys = function(keys) {
var str
, ok = true;
keys = keys instanceof Array
? keys
: Array.prototype.slice.call(arguments);
if (!keys.length) throw new Error('keys required');
var actual = Object.keys(this.obj)
, len = keys.length;
// Inclusion
ok = keys.every(function(key){
return ~actual.indexOf(key);
});
// Strict
if (!this.negate && !this.contains) {
ok = ok && keys.length == actual.length;
}
// Key string
if (len > 1) {
keys = keys.map(function(key){
return inspect(key);
});
var last = keys.pop();
str = keys.join(', ') + ', and ' + last;
} else {
str = inspect(keys[0]);
}
// Form
str = (len > 1 ? 'keys ' : 'key ') + str;
// Have / include
str = (this.contains ? 'contain ' : 'have ') + str;
// Assertion
this.assert(
ok
, 'expected ' + this.inspect + ' to ' + str
, 'expected ' + this.inspect + ' to not ' + str
, keys
, Object.keys(this.obj)
);
return this;
}
/**
* # .throw(constructor)
*
* Assert that a function will throw a specific type of error or that error
* thrown will match a RegExp or include a string.
*
* var fn = function () { throw new ReferenceError('This is a bad function.'); }
* expect(fn).to.throw(ReferenceError);
* expect(fn).to.throw(/bad function/);
* expect(fn).to.not.throw('good function');
* expect(fn).to.throw(ReferenceError, /bad function/);
*
* Please note that when a throw expectation is negated, it will check each
* parameter independently, starting with Error constructor type. The appropriate way
* to check for the existence of a type of error but for a message that does not match
* is to use `and`.
*
* expect(fn).to.throw(ReferenceError).and.not.throw(/good function/);
*
* @name throw
* @alias throws
* @alias Throw
* @param {ErrorConstructor} constructor
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @api public
*/
Assertion.prototype.throw = function (constructor, msg) {
new Assertion(this.obj).is.a('function');
var thrown = false;
if (arguments.length === 0) {
msg = null;
constructor = null;
} else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
msg = constructor;
constructor = null;
}
try {
this.obj();
} catch (err) {
// first, check constructor
if (constructor && 'function' === typeof constructor) {
this.assert(
err instanceof constructor && err.name == constructor.name
, 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'
, 'expected ' + this.inspect + ' to not throw ' + constructor.name );
if (!msg) return this;
}
// next, check message
if (err.message && msg && msg instanceof RegExp) {
this.assert(
msg.exec(err.message)
, 'expected ' + this.inspect + ' to throw error matching ' + msg + ' but got ' + inspect(err.message)
, 'expected ' + this.inspect + ' to throw error not matching ' + msg
);
return this;
} else if (err.message && msg && 'string' === typeof msg) {
this.assert(
~err.message.indexOf(msg)
, 'expected ' + this.inspect + ' to throw error including ' + inspect(msg) + ' but got ' + inspect(err.message)
, 'expected ' + this.inspect + ' to throw error not including ' + inspect(msg)
);
return this;
} else {
thrown = true;
}
}
var name = (constructor ? constructor.name : 'an error');
this.assert(
thrown === true
, 'expected ' + this.inspect + ' to throw ' + name
, 'expected ' + this.inspect + ' to not throw ' + name);
return this;
};
/**
* # .respondTo(method)
*
* Assert that object/class will respond to a method.
*
* expect(Klass).to.respondTo('bar');
* expect(obj).to.respondTo('bar');
*
* @name respondTo
* @param {String} method
* @api public
*/
Assertion.prototype.respondTo = function (method) {
var context = ('function' === typeof this.obj)
? this.obj.prototype[method]
: this.obj[method];
this.assert(
'function' === typeof context
, 'expected ' + this.inspect + ' to respond to ' + inspect(method)
, 'expected ' + this.inspect + ' to not respond to ' + inspect(method)
, 'function'
, typeof context
);
return this;
};
/**
* # .satisfy(method)
*
* Assert that passes a truth test.
*
* expect(1).to.satisfy(function(num) { return num > 0; });
*
* @name satisfy
* @param {Function} matcher
* @api public
*/
Assertion.prototype.satisfy = function (matcher) {
this.assert(
matcher(this.obj)
, 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)
, 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher)
, this.negate ? false : true
, matcher(this.obj)
);
return this;
};
/**
* # .closeTo(expected, delta)
*
* Assert that actual is equal to +/- delta.
*
* expect(1.5).to.be.closeTo(1, 0.5);
*
* @name closeTo
* @param {Number} expected
* @param {Number} delta
* @api public
*/
Assertion.prototype.closeTo = function (expected, delta) {
this.assert(
(this.obj - delta === expected) || (this.obj + delta === expected)
, 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta
, 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);
return this;
};
/*!
* Aliases.
*/
(function alias(name, as){
Assertion.prototype[as] = Assertion.prototype[name];
return alias;
})
('length', 'lengthOf')
('keys', 'key')
('ownProperty', 'haveOwnProperty')
('above', 'greaterThan')
('below', 'lessThan')
('throw', 'throws')
('throw', 'Throw') // for troublesome browsers
('instanceof', 'instanceOf');
}); // module: assertion.js
require.register("chai.js", function(module, exports, require){
/*!
* chai
* http://chaijs.com
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
var used = [];
var exports = module.exports = {};
exports.version = '0.5.0';
exports.Assertion = require('./assertion');
exports.AssertionError = require('./error');
exports.inspect = require('./utils/inspect');
exports.use = function (fn) {
if (!~used.indexOf(fn)) {
fn(this);
used.push(fn);
}
return this;
};
var expect = require('./interface/expect');
exports.use(expect);
var should = require('./interface/should');
exports.use(should);
var assert = require('./interface/assert');
exports.use(assert);
}); // module: chai.js
require.register("error.js", function(module, exports, require){
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
var fail = require('./chai').fail;
module.exports = AssertionError;
/*!
* Inspired by node.js assert module
* https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
*/
function AssertionError (options) {
options = options || {};
this.name = 'AssertionError';
this.message = options.message;
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
var stackStartFunction = options.stackStartFunction || fail;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
}
}
AssertionError.prototype.__proto__ = Error.prototype;
AssertionError.prototype.toString = function() {
return this.message;
};
}); // module: error.js
require.register("interface/assert.js", function(module, exports, require){
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/**
* ### TDD Style Introduction
*
* The TDD style is exposed through `assert` interfaces. This provides
* the classic assert.`test` notation, similiar to that packaged with
* node.js. This assert module, however, provides several additional
* tests and is browser compatible.
*
* // assert
* var assert = require('chai').assert;
* , foo = 'bar';
*
* assert.typeOf(foo, 'string');
* assert.equal(foo, 'bar');
*
* #### Configuration
*
* By default, Chai does not show stack traces upon an AssertionError. This can
* be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
*
* var chai = require('chai');
* chai.Assertion.includeStack = true; // defaults to false
*/
module.exports = function (chai) {
/*!
* Chai dependencies.
*/
var Assertion = chai.Assertion
, inspect = chai.inspect;
/*!
* Module export.
*/
var assert = chai.assert = {};
/**
* # .ok(object, [message])
*
* Assert object is truthy.
*
* assert.ok('everthing', 'everything is ok');
* assert.ok(false, 'this will fail');
*
* @name ok
* @param {*} object to test
* @param {String} message
* @api public
*/
assert.ok = function (val, msg) {
new Assertion(val, msg).is.ok;
};
/**
* # .equal(actual, expected, [message])
*
* Assert strict equality.
*
* assert.equal(3, 3, 'these numbers are equal');
*
* @name equal
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.equal = function (act, exp, msg) {
var test = new Assertion(act, msg);
test.assert(
exp == test.obj
, 'expected ' + test.inspect + ' to equal ' + inspect(exp)
, 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
};
/**
* # .notEqual(actual, expected, [message])
*
* Assert not equal.
*
* assert.notEqual(3, 4, 'these numbers are not equal');
*
* @name notEqual
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.notEqual = function (act, exp, msg) {
var test = new Assertion(act, msg);
test.assert(
exp != test.obj
, 'expected ' + test.inspect + ' to equal ' + inspect(exp)
, 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
};
/**
* # .strictEqual(actual, expected, [message])
*
* Assert strict equality.
*
* assert.strictEqual(true, true, 'these booleans are strictly equal');
*
* @name strictEqual
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.strictEqual = function (act, exp, msg) {
new Assertion(act, msg).to.equal(exp);
};
/**
* # .notStrictEqual(actual, expected, [message])
*
* Assert strict equality.
*
* assert.notStrictEqual(1, true, 'these booleans are not strictly equal');
*
* @name notStrictEqual
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.notStrictEqual = function (act, exp, msg) {
new Assertion(act, msg).to.not.equal(exp);
};
/**
* # .deepEqual(actual, expected, [message])
*
* Assert not deep equality.
*
* assert.deepEqual({ tea: 'green' }, { tea: 'green' });
*
* @name deepEqual
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.deepEqual = function (act, exp, msg) {
new Assertion(act, msg).to.eql(exp);
};
/**
* # .notDeepEqual(actual, expected, [message])
*
* Assert not deep equality.
*
* assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
*
* @name notDeepEqual
* @param {*} actual
* @param {*} expected
* @param {String} message
* @api public
*/
assert.notDeepEqual = function (act, exp, msg) {
new Assertion(act, msg).to.not.eql(exp);
};
/**
* # .isTrue(value, [message])
*
* Assert `value` is true.
*
* var tea_served = true;
* assert.isTrue(tea_served, 'the tea has been served');
*
* @name isTrue
* @param {Boolean} value
* @param {String} message
* @api public
*/
assert.isTrue = function (val, msg) {
new Assertion(val, msg).is.true;
};
/**
* # .isFalse(value, [message])
*
* Assert `value` is false.
*
* var tea_served = false;
* assert.isFalse(tea_served, 'no tea yet? hmm...');
*
* @name isFalse
* @param {Boolean} value
* @param {String} message
* @api public
*/
assert.isFalse = function (val, msg) {
new Assertion(val, msg).is.false;
};
/**
* # .isNull(value, [message])
*
* Assert `value` is null.
*
* assert.isNull(err, 'no errors');
*
* @name isNull
* @param {*} value
* @param {String} message
* @api public
*/
assert.isNull = function (val, msg) {
new Assertion(val, msg).to.equal(null);
};
/**
* # .isNotNull(value, [message])
*
* Assert `value` is not null.
*
* var tea = 'tasty chai';
* assert.isNotNull(tea, 'great, time for tea!');
*
* @name isNotNull
* @param {*} value
* @param {String} message
* @api public
*/
assert.isNotNull = function (val, msg) {
new Assertion(val, msg).to.not.equal(null);
};
/**
* # .isUndefined(value, [message])
*
* Assert `value` is undefined.
*
* assert.isUndefined(tea, 'no tea defined');
*
* @name isUndefined
* @param {*} value
* @param {String} message
* @api public
*/
assert.isUndefined = function (val, msg) {
new Assertion(val, msg).to.equal(undefined);
};
/**
* # .isFunction(value, [message])
*
* Assert `value` is a function.
*
* var serve_tea = function () { return 'cup of tea'; };
* assert.isFunction(serve_tea, 'great, we can have tea now');
*
* @name isFunction
* @param {Function} value
* @param {String} message
* @api public
*/
assert.isFunction = function (val, msg) {
new Assertion(val, msg).to.be.a('function');
};
/**
* # .isObject(value, [message])
*
* Assert `value` is an object.
*
* var selection = { name: 'Chai', serve: 'with spices' };
* assert.isObject(selection, 'tea selection is an object');
*
* @name isObject
* @param {Object} value
* @param {String} message
* @api public
*/
assert.isObject = function (val, msg) {
new Assertion(val, msg).to.be.a('object');
};
/**
* # .isArray(value, [message])
*
* Assert `value` is an instance of Array.
*
* var menu = [ 'green', 'chai', 'oolong' ];
* assert.isArray(menu, 'what kind of tea do we want?');
*
* @name isArray
* @param {*} value
* @param {String} message
* @api public
*/
assert.isArray = function (val, msg) {
new Assertion(val, msg).to.be.instanceof(Array);
};
/**
* # .isString(value, [message])
*
* Assert `value` is a string.
*
* var teaorder = 'chai';
* assert.isString(tea_order, 'order placed');
*
* @name isString
* @param {String} value
* @param {String} message
* @api public
*/
assert.isString = function (val, msg) {
new Assertion(val, msg).to.be.a('string');
};
/**
* # .isNumber(value, [message])
*
* Assert `value` is a number
*
* var cups = 2;
* assert.isNumber(cups, 'how many cups');
*
* @name isNumber
* @param {Number} value
* @param {String} message
* @api public
*/
assert.isNumber = function (val, msg) {
new Assertion(val, msg).to.be.a('number');
};
/**
* # .isBoolean(value, [message])
*
* Assert `value` is a boolean
*
* var teaready = true
* , teaserved = false;
*
* assert.isBoolean(tea_ready, 'is the tea ready');
* assert.isBoolean(tea_served, 'has tea been served');
*
* @name isBoolean
* @param {*} value
* @param {String} message
* @api public
*/
assert.isBoolean = function (val, msg) {
new Assertion(val, msg).to.be.a('boolean');
};
/**
* # .typeOf(value, name, [message])
*
* Assert typeof `value` is `name`.
*
* assert.typeOf('tea', 'string', 'we have a string');
*
* @name typeOf
* @param {*} value
* @param {String} typeof name
* @param {String} message
* @api public
*/
assert.typeOf = function (val, type, msg) {
new Assertion(val, msg).to.be.a(type);
};
/**
* # .instanceOf(object, constructor, [message])
*
* Assert `value` is instanceof `constructor`.
*
* var Tea = function (name) { this.name = name; }
* , Chai = new Tea('chai');
*
* assert.instanceOf(Chai, Tea, 'chai is an instance of tea');
*
* @name instanceOf
* @param {Object} object
* @param {Constructor} constructor
* @param {String} message
* @api public
*/
assert.instanceOf = function (val, type, msg) {
new Assertion(val, msg).to.be.instanceof(type);
};
/**
* # .include(value, includes, [message])
*
* Assert the inclusion of an object in another. Works
* for strings and arrays.
*
* assert.include('foobar', 'bar', 'foobar contains string `var`);
* assert.include([ 1, 2, 3], 3, 'array contains value);
*
* @name include
* @param {Array|String} value
* @param {*} includes
* @param {String} message
* @api public
*/
assert.include = function (exp, inc, msg) {
var obj = new Assertion(exp, msg);
if (Array.isArray(exp)) {
obj.to.include(inc);
} else if ('string' === typeof exp) {
obj.to.contain.string(inc);
}
};
/**
* # .match(value, regex, [message])
*
* Assert that `value` matches regular expression.
*
* assert.match('foobar', /^foo/, 'Regexp matches');
*
* @name match
* @param {*} value
* @param {RegExp} RegularExpression
* @param {String} message
* @api public
*/
assert.match = function (exp, re, msg) {
new Assertion(exp, msg).to.match(re);
};
/**
* # .length(value, constructor, [message])
*
* Assert that object has expected length.
*
* assert.length([1,2,3], 3, 'Array has length of 3');
* assert.length('foobar', 5, 'String has length of 6');
*
* @name length
* @param {*} value
* @param {Number} length
* @param {String} message
* @api public
*/
assert.length = function (exp, len, msg) {
new Assertion(exp, msg).to.have.length(len);
};
/**
* # .throws(function, [constructor/regexp], [message])
*
* Assert that a function will throw a specific
* type of error.
*
* assert.throw(fn, ReferenceError, 'function throw reference error');
*
* @name throws
* @alias throw
* @param {Function} function to test
* @param {ErrorConstructor} constructor
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @api public
*/
assert.throws = function (fn, type, msg) {
if ('string' === typeof type) {
msg = type;
type = null;
}
new Assertion(fn, msg).to.throw(type);
};
/**
* # .doesNotThrow(function, [constructor/regexp], [message])
*
* Assert that a function will throw a specific
* type of error.
*
* var fn = function (err) { if (err) throw Error(err) };
* assert.doesNotThrow(fn, Error, 'function throw reference error');
*
* @name doesNotThrow
* @param {Function} function to test
* @param {ErrorConstructor} constructor
* @param {String} message
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
* @api public
*/
assert.doesNotThrow = function (fn, type, msg) {
if ('string' === typeof type) {
msg = type;
type = null;
}
new Assertion(fn, msg).to.not.throw(type);
};
/**
* # .operator(val, operator, val2, [message])
*
* Compare two values using operator.
*
* assert.operator(1, '<', 2, 'everything is ok');
* assert.operator(1, '>', 2, 'this will fail');
*
* @name operator
* @param {*} object to test
* @param {String} operator
* @param {*} second object
* @param {String} message
* @api public
*/
assert.operator = function (val, operator, val2, msg) {
if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
throw new Error('Invalid operator "' + operator + '"');
}
new Assertion(eval(val + operator + val2), msg).to.be.true;
};
/*!
* Undocumented / untested
*/
assert.ifError = function (val, msg) {
new Assertion(val, msg).to.not.be.ok;
};
/*!
* Aliases.
*/
(function alias(name, as){
assert[as] = assert[name];
return alias;
})
('length', 'lengthOf')
('throws', 'throw');
};
}); // module: interface/assert.js
require.register("interface/expect.js", function(module, exports, require){
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
module.exports = function (chai) {
chai.expect = function (val, message) {
return new chai.Assertion(val, message);
};
};
}); // module: interface/expect.js
require.register("interface/should.js", function(module, exports, require){
/*!
* chai
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
module.exports = function (chai) {
var Assertion = chai.Assertion;
chai.should = function () {
// modify Object.prototype to have `should`
Object.defineProperty(Object.prototype, 'should', {
set: function(){},
get: function(){
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this));
} else if (this instanceof Boolean) {
return new Assertion(this == true);
}
return new Assertion(this);
},
configurable: true
});
var should = {};
should.equal = function (val1, val2) {
new Assertion(val1).to.equal(val2);
};
should.throw = function (fn, errt, errs) {
new Assertion(fn).to.throw(errt, errs);
};
should.exist = function (val) {
new Assertion(val).to.exist;
}
// negation
should.not = {}
should.not.equal = function (val1, val2) {
new Assertion(val1).to.not.equal(val2);
};
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;
}
return should;
};
};
}); // module: interface/should.js
require.register("utils/eql.js", function(module, exports, require){
// This is directly from Node.js assert
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
module.exports = _deepEqual;
// For browser implementation
if (!Buffer) {
var Buffer = {
isBuffer: function () {
return false;
}
};
}
function _deepEqual(actual, expected) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
if (actual.length != expected.length) return false;
for (var i = 0; i < actual.length; i++) {
if (actual[i] !== expected[i]) return false;
}
return true;
// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (typeof actual != 'object' && typeof expected != 'object') {
return actual === expected;
// 7.4. For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected);
}
}
function isUndefinedOrNull(value) {
return value === null || value === undefined;
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b) {
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b);
}
try {
var ka = Object.keys(a),
kb = Object.keys(b),
key, i;
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key])) return false;
}
return true;
}
}); // module: utils/eql.js
require.register("utils/inspect.js", function(module, exports, require){
// This is (almost) directly from Node.js utils
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
module.exports = inspect;
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} obj The object to print out.
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
* properties of objects.
* @param {Number} depth Depth in which to descend in object. Default is 2.
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
* output. Default is false (no coloring).
*/
function inspect(obj, showHidden, depth, colors) {
var ctx = {
showHidden: showHidden,
seen: [],
stylize: function (str) { return str; }
};
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
}
function formatValue(ctx, value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value.inspect !== exports.inspect &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
}
// Primitive types cannot have properties
var primitive = formatPrimitive(ctx, value);
if (primitive) {
return primitive;
}
// Look up the keys of the object.
var visibleKeys = Object.keys(value);
var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
// Some type of object without properties can be shortcutted.
if (keys.length === 0) {
if (typeof value === 'function') {
var name = value.name ? ': ' + value.name : '';
return ctx.stylize('[Function' + name + ']', 'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
}
if (isDate(value)) {
return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
}
if (isError(value)) {
return formatError(value);
}
}
var base = '', array = false, braces = ['{', '}'];
// Make Array say that they are Array
if (isArray(value)) {
array = true;
braces = ['[', ']'];
}
// Make functions say that they are functions
if (typeof value === 'function') {
var n = value.name ? ': ' + value.name : '';
base = ' [Function' + n + ']';
}
// Make RegExps say that they are RegExps
if (isRegExp(value)) {
base = ' ' + RegExp.prototype.toString.call(value);
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + Date.prototype.toUTCString.call(value);
}
// Make error with message first say the error
if (isError(value)) {
base = ' ' + formatError(value);
}
if (keys.length === 0 && (!array || value.length == 0)) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
} else {
return ctx.stylize('[Object]', 'special');
}
}
ctx.seen.push(value);
var output;
if (array) {
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
} else {
output = keys.map(function(key) {
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
});
}
ctx.seen.pop();
return reduceToSingleString(output, base, braces);
}
function formatPrimitive(ctx, value) {
switch (typeof value) {
case 'undefined':
return ctx.stylize('undefined', 'undefined');
case 'string':
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
.replace(/'/g, "\\'")
.replace(/\\"/g, '"') + '\'';
return ctx.stylize(simple, 'string');
case 'number':
return ctx.stylize('' + value, 'number');
case 'boolean':
return ctx.stylize('' + value, 'boolean');
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
return ctx.stylize('null', 'null');
}
}
function formatError(value) {
return '[' + Error.prototype.toString.call(value) + ']';
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
var output = [];
for (var i = 0, l = value.length; i < l; ++i) {
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
} else {
output.push('');
}
}
keys.forEach(function(key) {
if (!key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
}
});
return output;
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
var name, str;
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
str = ctx.stylize('[Getter/Setter]', 'special');
} else {
str = ctx.stylize('[Getter]', 'special');
}
} else {
if (value.__lookupSetter__(key)) {
str = ctx.stylize('[Setter]', 'special');
}
}
}
if (visibleKeys.indexOf(key) < 0) {
name = '[' + key + ']';
}
if (!str) {
if (ctx.seen.indexOf(value[key]) < 0) {
if (recurseTimes === null) {
str = formatValue(ctx, value[key], null);
} else {
str = formatValue(ctx, value[key], recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (array) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = ctx.stylize('[Circular]', 'special');
}
}
if (typeof name === 'undefined') {
if (array && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
name = ctx.stylize(name, 'name');
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = ctx.stylize(name, 'string');
}
}
return name + ': ' + str;
}
function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.length + 1;
}, 0);
if (length > 60) {
return braces[0] +
(base === '' ? '' : base + '\n ') +
' ' +
output.join(',\n ') +
' ' +
braces[1];
}
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
function isArray(ar) {
return Array.isArray(ar) ||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
}
function isRegExp(re) {
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
}
function isDate(d) {
return typeof d === 'object' && objectToString(d) === '[object Date]';
}
function isError(e) {
return typeof e === 'object' && objectToString(e) === '[object Error]';
}
function objectToString(o) {
return Object.prototype.toString.call(o);
}
}); // module: utils/inspect.js
return require('chai');
});
\ No newline at end of file
!function(i,g){"function"==typeof define&&"object"==typeof define.amd?define(g):this[i]=g()}("chai",function(){function i(g){var h=i.resolve(g),e=i.modules[h];if(!e)throw Error('failed to require "'+g+'"');e.exports||(e.exports={},e.call(e.exports,e,e.exports,i.relative(h)));return e.exports}i.modules={};i.resolve=function(g){var h=g+".js",e=g+"/index.js";return i.modules[h]&&h||i.modules[e]&&e||g};i.register=function(g,h){i.modules[g]=h};i.relative=function(g){return function(h){if("."!=h[0])return i(h);
var e=g.split("/"),h=h.split("/");e.pop();for(var c=0;c<h.length;c++){var j=h[c];".."==j?e.pop():"."!=j&&e.push(j)}return i(e.join("/"))}};i.register("assertion.js",function(g,h,e){function c(a,b,c){d(this,"ssfi",c||arguments.callee);d(this,"object",a);d(this,"message",b)}var j=e("./browser/error"),f=Object.prototype.toString,b=e("./utils"),d=b.flag;g.exports=c;c.includeStack=!1;c.addProperty=function(a,d){b.addProperty(this.prototype,a,d)};c.addMethod=function(a,d){b.addMethod(this.prototype,a,d)};
c.overwriteProperty=function(a,d){b.overwriteProperty(this.prototype,a,d)};c.overwriteMethod=function(a,d){b.overwriteMethod(this.prototype,a,d)};c.prototype.assert=function(a,f,e,h,r){var f=b.getMessage(this,arguments),m=b.getActual(this,arguments);if(!b.test(this,arguments))throw new j({message:f,actual:m,expected:h,stackStartFunction:c.includeStack?this.assert:d(this,"ssfi")});};Object.defineProperty(c.prototype,"_obj",{get:function(){return d(this,"object")},set:function(a){d(this,"object",a)}});
"to be been is and have with".split(" ").forEach(function(a){Object.defineProperty(c.prototype,a,{get:function(){return this},configurable:!0})});Object.defineProperty(c.prototype,"not",{get:function(){d(this,"negate",!0);return this},configurable:!0});Object.defineProperty(c.prototype,"deep",{get:function(){d(this,"deep",!0);return this},configurable:!0});g=function(){var a=function(a){var b=d(this,"object"),c=a.charAt(0).toUpperCase(),e=c+a.slice(1),c=~["A","E","I","O","U"].indexOf(c)?"an ":"a ";
this.assert("[object "+e+"]"===f.call(b),"expected #{this} to be "+c+a,"expected #{this} not to be "+c+a,"[object "+e+"]",f.call(b));return this};a.__proto__=this;return a};Object.defineProperty(c.prototype,"an",{get:g,configurable:!0});Object.defineProperty(c.prototype,"a",{get:g,configurable:!0});g=function(){d(this,"contains",!0);var a=function(a){this.assert(~d(this,"object").indexOf(a),"expected #{this} to include "+b.inspect(a),"expected #{this} to not include "+b.inspect(a));return this};a.__proto__=
this;return a};Object.defineProperty(c.prototype,"contain",{get:g,configurable:!0});Object.defineProperty(c.prototype,"include",{get:g,configurable:!0});Object.defineProperty(c.prototype,"ok",{get:function(){this.assert(d(this,"object"),"expected #{this} to be truthy","expected #{this} to be falsy");return this},configurable:!0});Object.defineProperty(c.prototype,"true",{get:function(){this.assert(!0===d(this,"object"),"expected #{this} to be true","expected #{this} to be false",this.negate?!1:!0);
return this},configurable:!0});Object.defineProperty(c.prototype,"false",{get:function(){this.assert(!1===d(this,"object"),"expected #{this} to be false","expected #{this} to be true",this.negate?!0:!1);return this},configurable:!0});Object.defineProperty(c.prototype,"null",{get:function(){this.assert(null===d(this,"object"),"expected #{this} to be null","expected #{this} not to be null",this.negate?!1:!0);return this},configurable:!0});Object.defineProperty(c.prototype,"undefined",{get:function(){this.assert(void 0===
d(this,"object"),"expected #{this} to be undefined","expected #{this} not to be undefined",this.negate?!1:!0);return this},configurable:!0});Object.defineProperty(c.prototype,"exist",{get:function(){this.assert(null!=d(this,"object"),"expected #{this} to exist","expected #{this} to not exist");return this},configurable:!0});Object.defineProperty(c.prototype,"empty",{get:function(){var a=d(this,"object"),b=a;Array.isArray(a)||"string"===typeof object?b=a.length:"object"===typeof a&&(b=Object.keys(a).length);
this.assert(!b,"expected #{this} to be empty","expected #{this} not to be empty");return this},configurable:!0});Object.defineProperty(c.prototype,"arguments",{get:function(){var a=d(this,"object");this.assert("[object Arguments]"==Object.prototype.toString.call(a),"expected #{this} to be arguments","expected #{this} to not be arguments","[object Arguments]",Object.prototype.toString.call(a));return this},configurable:!0});c.prototype.equal=function(a){var b=d(this,"object");d(this,"deep")?(new c(b)).to.eql(a):
this.assert(a===b,"expected #{this} to equal #{exp}","expected #{this} to not equal #{exp}",a);return this};c.prototype.eql=function(a){this.assert(b.eql(a,d(this,"object")),"expected #{this} to equal #{exp}","expected #{this} to not equal #{exp}",a);return this};c.prototype.above=function(a){this.assert(d(this,"object")>a,"expected #{this} to be above "+a,"expected #{this} to be below "+a);return this};c.prototype.below=function(a){this.assert(d(this,"object")<a,"expected #{this} to be below "+a,
"expected #{this} to be above "+a);return this};c.prototype.within=function(a,b){var c=d(this,"object"),f=a+".."+b;this.assert(c>=a&&c<=b,"expected #{this} to be within "+f,"expected #{this} to not be within "+f);return this};c.prototype.instanceOf=function(a){var c=b.getName(a);this.assert(d(this,"object")instanceof a,"expected #{this} to be an instance of "+c,"expected #{this} to not be an instance of "+c);return this};c.prototype.property=function(a,c){var f=d(this,"object"),e=d(this,"deep")?b.getPathValue(a,
f):f[a],h=d(this,"deep")?"deep property ":"property ";if(d(this,"negate")&&void 0!==c){if(void 0===e)throw Error(b.inspect(f)+" has no "+h+b.inspect(a));}else this.assert(void 0!==e,"expected #{this} to have a "+h+b.inspect(a),"expected #{this} to not have "+h+b.inspect(a));void 0!==c&&this.assert(c===e,"expected #{this} to have a "+h+b.inspect(a)+" of #{exp}, but got #{act}","expected #{this} to not have a "+h+b.inspect(a)+" of #{act}",c,e);d(this,"object",e);return this};c.prototype.ownProperty=
function(a){this.assert(d(this,"object").hasOwnProperty(a),"expected #{this} to have own property "+b.inspect(a),"expected #{this} to not have own property "+b.inspect(a));return this};c.prototype.length=function(a){var b=d(this,"object");(new c(b)).to.have.property("length");b=b.length;this.assert(b==a,"expected #{this} to have a length of #{exp} but got #{act}","expected #{this} to not have a length of #{act}",a,b);return this};c.prototype.match=function(a){var b=d(this,"object");this.assert(a.exec(b),
"expected #{this} to match "+a,"expected #{this} not to match "+a);return this};c.prototype.string=function(a){var f=d(this,"object");(new c(f)).is.a("string");this.assert(~f.indexOf(a),"expected #{this} to contain "+b.inspect(a),"expected #{this} to not contain "+b.inspect(a));return this};c.prototype.keys=function(a){var c=d(this,"object"),f,e=!0,a=a instanceof Array?a:Array.prototype.slice.call(arguments);if(!a.length)throw Error("keys required");var h=Object.keys(c),m=a.length,e=a.every(function(a){return~h.indexOf(a)});
!d(this,"negate")&&!d(this,"contains")&&(e=e&&a.length==h.length);1<m?(a=a.map(function(a){return b.inspect(a)}),f=a.pop(),f=a.join(", ")+", and "+f):f=b.inspect(a[0]);f=(d(this,"contains")?"contain ":"have ")+((1<m?"keys ":"key ")+f);this.assert(e,"expected #{this} to "+f,"expected #{this} to not "+f,a,Object.keys(c));return this};c.prototype.Throw=function(a,f){var e=d(this,"object");(new c(e)).is.a("function");var h=!1,g=null,m=null;0===arguments.length?a=f=null:a&&(a instanceof RegExp||"string"===
typeof a)?(f=a,a=null):a&&a instanceof Error?(g=a,f=a=null):"function"===typeof a?m=(new a).name:a=null;try{e()}catch(j){if(g)return this.assert(j===g,"expected #{this} to throw "+b.inspect(g)+" but "+b.inspect(j)+" was thrown","expected #{this} to not throw "+b.inspect(g)),this;if(a&&(this.assert(j instanceof a,"expected #{this} to throw "+m+" but a "+j.name+" was thrown","expected #{this} to not throw "+m),!f))return this;if(j.message&&f&&f instanceof RegExp)return this.assert(f.exec(j.message),
"expected #{this} to throw error matching "+f+" but got "+b.inspect(j.message),"expected #{this} to throw error not matching "+f),this;if(j.message&&f&&"string"===typeof f)return this.assert(~j.message.indexOf(f),"expected #{this} to throw error including #{exp} but got #{act}","expected #{this} to throw error not including #{act}",f,j.message),this;h=!0}e=m?m:g?b.inspect(g):"an error";this.assert(!0===h,"expected #{this} to throw "+e,"expected #{this} to not throw "+e);return this};c.prototype.respondTo=
function(a){var c=d(this,"object"),c="function"===typeof c?c.prototype[a]:c[a];this.assert("function"===typeof c,"expected #{this} to respond to "+b.inspect(a),"expected #{this} to not respond to "+b.inspect(a),"function",typeof c);return this};c.prototype.satisfy=function(a){var c=d(this,"object");this.assert(a(c),"expected #{this} to satisfy "+b.inspect(a),"expected #{this} to not satisfy"+b.inspect(a),this.negate?!1:!0,a(c));return this};c.prototype.closeTo=function(a,b){var c=d(this,"object");
this.assert(c-b===a||c+b===a,"expected #{this} to be close to "+a+" +/- "+b,"expected #{this} not to be close to "+a+" +/- "+b);return this};(function n(b,d){c.prototype[d]=c.prototype[b];return n})("equal","eq")("above","gt")("below","lt")("length","lengthOf")("keys","key")("ownProperty","haveOwnProperty")("above","greaterThan")("below","lessThan")("Throw","throws")("Throw","throw")("instanceOf","instanceof")});i.register("browser/error.js",function(g){function h(e){e=e||{};this.message=e.message;
this.actual=e.actual;this.expected=e.expected;this.operator=e.operator;e.stackStartFunction&&Error.captureStackTrace&&Error.captureStackTrace(this,e.stackStartFunction)}g.exports=h;h.prototype=Object.create(Error.prototype);h.prototype.name="AssertionError";h.prototype.constructor=h;h.prototype.toString=function(){return this.message}});i.register("chai.js",function(g,h,e){var c=[],h=g.exports={};h.version="1.0.1";h.Assertion=e("./assertion");h.AssertionError=e("./browser/error");var j=e("./utils");
h.use=function(f){~c.indexOf(f)||(f(this,j),c.push(f));return this};g=e("./interface/expect");h.use(g);g=e("./interface/should");h.use(g);e=e("./interface/assert");h.use(e)});i.register("interface/assert.js",function(g){g.exports=function(h,e){var c=h.Assertion,g=e.flag,f=h.assert=function(b,d){(new c(null)).assert(b,d,"[ negation message unavailable ]")};f.fail=function(b,d,a,c){throw new h.AssertionError({actual:b,expected:d,message:a,operator:c,stackStartFunction:f.fail});};f.ok=function(b,d){(new c(b,
d)).is.ok};f.equal=function(b,d,a){a=new c(b,a);a.assert(d==g(a,"object"),"expected #{this} to equal #{exp}","expected #{this} to not equal #{act}",d,b)};f.notEqual=function(b,d,a){a=new c(b,a);a.assert(d!=g(a,"object"),"expected #{this} to not equal #{exp}","expected #{this} to equal #{act}",d,b)};f.strictEqual=function(b,d,a){(new c(b,a)).to.equal(d)};f.notStrictEqual=function(b,d,a){(new c(b,a)).to.not.equal(d)};f.deepEqual=function(b,d,a){(new c(b,a)).to.eql(d)};f.notDeepEqual=function(b,d,a){(new c(b,
a)).to.not.eql(d)};f.isTrue=function(b,d){(new c(b,d)).is["true"]};f.isFalse=function(b,d){(new c(b,d)).is["false"]};f.isNull=function(b,d){(new c(b,d)).to.equal(null)};f.isNotNull=function(b,d){(new c(b,d)).to.not.equal(null)};f.isUndefined=function(b,d){(new c(b,d)).to.equal(void 0)};f.isDefined=function(b,d){(new c(b,d)).to.not.equal(void 0)};f.isFunction=function(b,d){(new c(b,d)).to.be.a("function")};f.isNotFunction=function(b,d){(new c(b,d)).to.not.be.a("function")};f.isObject=function(b,d){(new c(b,
d)).to.be.a("object")};f.isNotObject=function(b,d){(new c(b,d)).to.not.be.a("object")};f.isArray=function(b,d){(new c(b,d)).to.be.an("array")};f.isNotArray=function(b,d){(new c(b,d)).to.not.be.an("array")};f.isString=function(b,d){(new c(b,d)).to.be.a("string")};f.isNotString=function(b,d){(new c(b,d)).to.not.be.a("string")};f.isNumber=function(b,d){(new c(b,d)).to.be.a("number")};f.isNotNumber=function(b,d){(new c(b,d)).to.not.be.a("number")};f.isBoolean=function(b,d){(new c(b,d)).to.be.a("boolean")};
f.isNotBoolean=function(b,d){(new c(b,d)).to.not.be.a("boolean")};f.typeOf=function(b,d,a){(new c(b,a)).to.be.a(d)};f.notTypeOf=function(b,d,a){(new c(b,a)).to.not.be.a(d)};f.instanceOf=function(b,d,a){(new c(b,a)).to.be.instanceOf(d)};f.notInstanceOf=function(b,d,a){(new c(b,a)).to.not.be.instanceOf(d)};f.include=function(b,d,a){a=new c(b,a);Array.isArray(b)?a.to.include(d):"string"===typeof b&&a.to.contain.string(d)};f.match=function(b,d,a){(new c(b,a)).to.match(d)};f.notMatch=function(b,d,a){(new c(b,
a)).to.not.match(d)};f.property=function(b,d,a){(new c(b,a)).to.have.property(d)};f.notProperty=function(b,d,a){(new c(b,a)).to.not.have.property(d)};f.deepProperty=function(b,d,a){(new c(b,a)).to.have.deep.property(d)};f.notDeepProperty=function(b,d,a){(new c(b,a)).to.not.have.deep.property(d)};f.propertyVal=function(b,d,a,f){(new c(b,f)).to.have.property(d,a)};f.propertyNotVal=function(b,d,a,f){(new c(b,f)).to.not.have.property(d,a)};f.deepPropertyVal=function(b,d,a,f){(new c(b,f)).to.have.deep.property(d,
a)};f.deepPropertyNotVal=function(b,d,a,f){(new c(b,f)).to.not.have.deep.property(d,a)};f.lengthOf=function(b,d,a){(new c(b,a)).to.have.length(d)};f.Throw=function(b,d,a){"string"===typeof d&&(a=d,d=null);(new c(b,a)).to.Throw(d)};f.doesNotThrow=function(b,d,a){"string"===typeof d&&(a=d,d=null);(new c(b,a)).to.not.Throw(d)};f.operator=function(b,d,a,f){if(!~"== === > >= < <= != !==".split(" ").indexOf(d))throw Error('Invalid operator "'+d+'"');f=new c(eval(b+d+a),f);f.assert(!0===g(f,"object"),"expected "+
e.inspect(b)+" to be "+d+" "+e.inspect(a),"expected "+e.inspect(b)+" to not be "+d+" "+e.inspect(a))};f.ifError=function(b,d){(new c(b,d)).to.not.be.ok};(function d(a,c){f[c]=f[a];return d})("Throw","throw")("Throw","throws")}});i.register("interface/expect.js",function(g){g.exports=function(h){h.expect=function(e,c){return new h.Assertion(e,c)}}});i.register("interface/should.js",function(g){g.exports=function(h){function e(){Object.defineProperty(Object.prototype,"should",{set:function(){},get:function(){return this instanceof
String||this instanceof Number?new c(this.constructor(this)):this instanceof Boolean?new c(!0==this):new c(this)},configurable:!0});var e={equal:function(f,b){(new c(f)).to.equal(b)},Throw:function(f,b,d){(new c(f)).to.Throw(b,d)},exist:function(f){(new c(f)).to.exist},not:{}};e.not.equal=function(f,b){(new c(f)).to.not.equal(b)};e.not.Throw=function(f,b,d){(new c(f)).to.not.Throw(b,d)};e.not.exist=function(f){(new c(f)).to.not.exist};e["throw"]=e.Throw;e.not["throw"]=e.not.Throw;return e}var c=h.Assertion;
h.should=e;h.Should=e}});i.register("utils/addMethod.js",function(g){g.exports=function(h,e,c){h[e]=function(){var e=c.apply(this,arguments);return void 0===e?this:e}}});i.register("utils/addProperty.js",function(g){g.exports=function(h,e,c){Object.defineProperty(h,e,{get:function(){var e=c.call(this);return void 0===e?this:e},configurable:!0})}});i.register("utils/eql.js",function(g){function h(f,b){if(f===b)return!0;if(j.isBuffer(f)&&j.isBuffer(b)){if(f.length!=b.length)return!1;for(var d=0;d<f.length;d++)if(f[d]!==
b[d])return!1;return!0}return f instanceof Date&&b instanceof Date?f.getTime()===b.getTime():"object"!=typeof f&&"object"!=typeof b?f===b:c(f,b)}function e(c){return"[object Arguments]"==Object.prototype.toString.call(c)}function c(c,b){if(null===c||void 0===c||(null===b||void 0===b)||c.prototype!==b.prototype)return!1;if(e(c)){if(!e(b))return!1;c=pSlice.call(c);b=pSlice.call(b);return h(c,b)}try{var d=Object.keys(c),a=Object.keys(b),g}catch(j){return!1}if(d.length!=a.length)return!1;d.sort();a.sort();
for(g=d.length-1;0<=g;g--)if(d[g]!=a[g])return!1;for(g=d.length-1;0<=g;g--)if(a=d[g],!h(c[a],b[a]))return!1;return!0}g.exports=h;if(!j)var j={isBuffer:function(){return!1}}});i.register("utils/flag.js",function(g){g.exports=function(h,e,c){var g=h.__flags||(h.__flags=Object.create(null));if(3===arguments.length)g[e]=c;else return g[e]}});i.register("utils/getActual.js",function(g){g.exports=function(h,e){var c=e[4];return"undefined"!==c?c:h.obj}});i.register("utils/getMessage.js",function(g,h,e){var c=
e("./flag"),j=e("./getActual"),f=e("./inspect");g.exports=function(b,d){var a=c(b,"negate"),e=c(b,"object"),h=d[3],g=j(b,d),a=a?d[2]:d[1],r=c(b,"message"),a=(a||"").replace(/#{this}/g,f(e)).replace(/#{act}/g,f(g)).replace(/#{exp}/g,f(h));return r?r+": "+a:a}});i.register("utils/getName.js",function(g){g.exports=function(h){return h.name?h.name:(h=/^\s?function ([^(]*)\(/.exec(h))&&h[1]?h[1]:""}});i.register("utils/getPathValue.js",function(g){function h(e){return e.split(".").filter(Boolean).map(function(c){var e=
/([A-Za-z0-9]+)\[(\d+)\]$/.exec(c),f;e&&(f={p:e[1],i:parseFloat(e[2])});return f||c})}g.exports=function(e,c){for(var g=h(e),f=c,b,d=0,a=g.length;d<a;d++){var i=g[d];f?(f="object"===typeof i&&f[i.p]?f[i.p][i.i]:f[i],d==a-1&&(b=f)):b=void 0}return b}});i.register("utils/index.js",function(g,h,e){h=g.exports={};h.test=e("./test");h.getMessage=e("./getMessage");h.getActual=e("./getActual");h.inspect=e("./inspect");h.flag=e("./flag");h.eql=e("./eql");h.getPathValue=e("./getPathValue");h.getName=e("./getName");
h.addProperty=e("./addProperty");h.addMethod=e("./addMethod");h.overwriteProperty=e("./overwriteProperty");h.overwriteMethod=e("./overwriteMethod")});i.register("utils/inspect.js",function(g,h,e){function c(c,e,g){if(e&&"function"===typeof e.inspect&&e.inspect!==h.inspect&&!(e.constructor&&e.constructor.prototype===e))return e.inspect(g);var k=i(c,e);if(k)return k;var s=Object.keys(e),l=c.showHidden?Object.getOwnPropertyNames(e):s;if(0===l.length||q(e)&&(1===l.length&&"stack"===l[0]||2===l.length&&
"description"===l[0]&&"stack"===l[1])){if("function"===typeof e)return k=t(e),c.stylize("[Function"+(k?": "+k:"")+"]","special");if(a(e))return c.stylize(RegExp.prototype.toString.call(e),"regexp");if(n(e))return c.stylize(Date.prototype.toUTCString.call(e),"date");if(q(e))return"["+Error.prototype.toString.call(e)+"]"}var k="",o=!1,p=["{","}"];if(Array.isArray(e)||"object"===typeof e&&"[object Array]"===Object.prototype.toString.call(e))o=!0,p=["[","]"];"function"===typeof e&&(k=" [Function"+(e.name?
": "+e.name:"")+"]");a(e)&&(k=" "+RegExp.prototype.toString.call(e));n(e)&&(k=" "+Date.prototype.toUTCString.call(e));q(e)&&(k=" "+("["+Error.prototype.toString.call(e)+"]"));if(0===l.length&&(!o||0==e.length))return p[0]+k+p[1];if(0>g)return a(e)?c.stylize(RegExp.prototype.toString.call(e),"regexp"):c.stylize("[Object]","special");c.seen.push(e);l=o?f(c,e,g,s,l):l.map(function(a){return b(c,e,g,s,a,o)});c.seen.pop();return d(l,k,p)}function i(a,b){switch(typeof b){case "undefined":return a.stylize("undefined",
"undefined");case "string":var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string");case "number":return a.stylize(""+b,"number");case "boolean":return a.stylize(""+b,"boolean")}if(null===b)return a.stylize("null","null")}function f(a,c,d,e,f){for(var h=[],g=0,i=c.length;g<i;++g)Object.prototype.hasOwnProperty.call(c,""+g)?h.push(b(a,c,d,e,""+g,!0)):h.push("");f.forEach(function(f){f.match(/^\d+$/)||h.push(b(a,c,d,e,f,!0))});return h}
function b(a,b,d,e,f,h){var g,i;b.__lookupGetter__&&(b.__lookupGetter__(f)?i=b.__lookupSetter__(f)?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):b.__lookupSetter__(f)&&(i=a.stylize("[Setter]","special")));0>e.indexOf(f)&&(g="["+f+"]");i||(0>a.seen.indexOf(b[f])?(i=null===d?c(a,b[f],null):c(a,b[f],d-1),-1<i.indexOf("\n")&&(i=h?i.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+i.split("\n").map(function(a){return" "+a}).join("\n"))):i=a.stylize("[Circular]",
"special"));if("undefined"===typeof g){if(h&&f.match(/^\d+$/))return i;g=JSON.stringify(""+f);g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+i}function d(a,b,c){var d=0;return 60<a.reduce(function(a,b){d++;0<=b.indexOf("\n")&&d++;return a+b.length+1},0)?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function a(a){return"object"===
typeof a&&"[object RegExp]"===Object.prototype.toString.call(a)}function n(a){return"object"===typeof a&&"[object Date]"===Object.prototype.toString.call(a)}function q(a){return"object"===typeof a&&"[object Error]"===Object.prototype.toString.call(a)}var t=e("./getName");g.exports=function(a,b,d){return c({showHidden:b,seen:[],stylize:function(a){return a}},a,"undefined"===typeof d?2:d)}});i.register("utils/overwriteMethod.js",function(g){g.exports=function(g,e,c){var i=g[e],f=function(){return this};
i&&"function"===typeof i&&(f=i);g[e]=function(){var b=c(f).apply(this,arguments);return void 0===b?this:b}}});i.register("utils/overwriteProperty.js",function(g){g.exports=function(g,e,c){var i=Object.getOwnPropertyDescriptor(g,e),f=function(){};i&&"function"===typeof i.get&&(f=i.get);Object.defineProperty(g,e,{get:function(){var b=c(f).call(this);return b===void 0?this:b},configurable:!0})}});i.register("utils/test.js",function(g,h,e){var c=e("./flag");g.exports=function(e,f){var b=c(e,"negate"),
d=f[0];return b?!d:d}});return i("chai")});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment