webpack
Version:
Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.
1,465 lines (1,183 loc) • 71.2 kB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded chunks
/******/ // "1" means "already loaded"
/******/ var installedChunks = {
/******/ 0:1
/******/ };
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
/******/ if(installedChunks[chunkId] === 1) callback.call(null, __webpack_require__);
/******/ else if(!installedChunks[chunkId]) {
/******/ installedChunks[chunkId] = [callback];
/******/ var filename = __dirname + "/" + chunkId + ".bundle.js";
/******/ require('fs').readFile(filename, 'utf-8', function(err, content) {
/******/ if(err) { if(__webpack_require__.onError) return __webpack_require__.onError(err); else throw err; }
/******/ var chunk = {};
/******/ require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\n})', filename)(chunk, require, require('path').dirname(filename), filename);
/******/ var moreModules = chunk.modules, chunkIds = chunk.ids;
/******/ for(var moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ var callbacks = [];
/******/ for(var i = 0; i < chunkIds.length; i++) {
/******/ if(Array.isArray(installedChunks[chunkIds[i]]))
/******/ callbacks = callbacks.concat(installedChunks[chunkIds[i]]);
/******/ installedChunks[chunkIds[i]] = 1;
/******/ }
/******/ for(i = 0; i < callbacks.length; i++)
/******/ callbacks[i].call(null, __webpack_require__);
/******/ });
/******/ } else installedChunks[chunkId].push(callback);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!**************************************!*\
!*** ./parsing/extract-amd/index.js ***!
\**************************************/
/***/ function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {var should = __webpack_require__(/*! should */ 13);
it("should parse fancy function calls", function() {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./constructor */ 1)], __WEBPACK_AMD_DEFINE_RESULT__ = function(c) {
return new c(1324);
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
module.exports.should.have.property("value").be.eql(1324);
(!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./constructor */ 1)], __WEBPACK_AMD_DEFINE_RESULT__ = function(c) {
return new c(4231);
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)));
module.exports.should.have.property("value").be.eql(4231);
});
it("should parse fancy AMD calls", function() {
!/* require */(/* empty */[__webpack_require__(/*! ./constructor */ 1), __webpack_require__(/*! ./a */ 2)]);
!/* require */(/* empty */function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__, module, exports, __webpack_require__(/*! ./constructor */ 1), __webpack_require__(/*! ./a */ 2)]; (function(require, module, exports, constructor, a) {
("function").should.be.eql("function");
(typeof module).should.be.eql("object");
(typeof exports).should.be.eql("object");
(typeof __webpack_require__(/*! ./constructor */ 1)).should.be.eql("function");
(typeof constructor).should.be.eql("function");
a.should.be.eql("a");
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}());
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, module, exports, __webpack_require__(/*! ./constructor */ 1), __webpack_require__(/*! ./a */ 2)], __WEBPACK_AMD_DEFINE_RESULT__ = function(require, module, exports, constructor, a) {
("function").should.be.eql("function");
(typeof module).should.be.eql("object");
(typeof exports).should.be.eql("object");
(typeof __webpack_require__(/*! ./constructor */ 1)).should.be.eql("function");
(typeof constructor).should.be.eql("function");
a.should.be.eql("a");
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use AMD-style require", function(done) {
var template = "b";
__webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./circular */ 3), __webpack_require__(/*! ./templates */ 5)("./" + template), __webpack_require__(/*! ./circular */ 3)]; (function(circular, testTemplate, circular2) {
circular.should.be.eql(1);
circular2.should.be.eql(1);
testTemplate.should.be.eql("b");
done();
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
});
it("should be able to use require.js-style define", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./circular */ 3)], __WEBPACK_AMD_DEFINE_RESULT__ = function(circular) {
circular.should.be.eql(1);
done();
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, optional dependancies, not exist", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./optional */ 4)], __WEBPACK_AMD_DEFINE_RESULT__ = function(optional) {
should(optional.b).not.exist;
done();
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, special string", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__], __WEBPACK_AMD_DEFINE_RESULT__ = function(require) {
__webpack_require__(/*! ./circular */ 3).should.be.eql(1);
done();
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, without name", function(done) {
true && !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./circular */ 3)], __WEBPACK_AMD_DEFINE_RESULT__ = function(circular) {
circular.should.be.eql(1);
done();
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, with empty dependencies", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
done();
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, with empty dependencies, with a expression", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (ok), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
function ok() { done() };
});
it("should be able to use require.js-style define, with empty dependencies, with a expression and name", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (done), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, without dependencies", function(done) {
true && !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
done();
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should be able to use require.js-style define, without dependencies, with a expression", function(done) {
true && !(__WEBPACK_AMD_DEFINE_FACTORY__ = (ok), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
function ok() { done() };
});
var obj = {};
it("should be able to use require.js-style define, with an object", function() {
module.exports = null;
true && !(__WEBPACK_AMD_DEFINE_FACTORY__ = (obj), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
module.exports.should.be.equal(obj);
module.exports = null;
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (obj), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
module.exports.should.be.equal(obj);
module.exports = null;
});
it("should offer AMD-style define for CommonJs", function(done) {
var _test_exports = exports;
var _test_module = module;
!(__WEBPACK_AMD_DEFINE_RESULT__ = function(require, exports, module) {
("function").should.be.eql("function");
exports.should.be.equal(_test_exports);
module.should.be.equal(_test_module);
__webpack_require__(/*! ./circular */ 3).should.be.eql(1);
done();
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should not crash on require.js require only with array", function() {
!/* require */(/* empty */[__webpack_require__(/*! ./circular */ 3)]);
});
it("should be able to use AMD require without function expression (empty array)", function(done) {
!/* require */(/* empty */function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = []; (ok.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}());
function ok() { done() };
});
it("should be able to use AMD require without function expression", function(done) {
!/* require */(/* empty */function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./circular */ 3)]; (fn.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}());
function fn(c) {
c.should.be.eql(1);
done();
}
});
it("should create a chunk for require.js require", function(done) {
var sameTick = true;
__webpack_require__.e/* require */(2, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./c */ 6)]; (function(c) {
sameTick.should.be.eql(false);
c.should.be.eql("c");
__webpack_require__(/*! ./d */ 7).should.be.eql("d");
done();
}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));});
sameTick = false;
});
it("should not fail #138", function(done) {
(function (factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); // AMD
} else if (typeof exports === 'object') {
module.exports = factory(); // Node
} else {
factory(); // Browser global
}
}(function () { done() }));
});
it("should parse a bound function expression 1", function(done) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = function(a, require, exports, module) {
a.should.be.eql(123);
("function").should.be.eql("function");
__webpack_require__(/*! ./a */ 2).should.be.eql("a");
done();
}.bind(null, 123).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should parse a bound function expression 2", function(done) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = function(a, require, exports, module) {
a.should.be.eql(123);
("function").should.be.eql("function");
__webpack_require__(/*! ./a */ 2).should.be.eql("a");
done();
}.bind(null, 123).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should parse a bound function expression 3", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./a */ 2)], __WEBPACK_AMD_DEFINE_RESULT__ = function(number, a) {
number.should.be.eql(123);
a.should.be.eql("a");
done();
}.bind(null, 123).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should parse a bound function expression 4", function(done) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./a */ 2)], __WEBPACK_AMD_DEFINE_RESULT__ = function(number, a) {
number.should.be.eql(123);
a.should.be.eql("a");
done();
}.bind(null, 123).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
});
it("should not fail issue #138 second", function() {
(function(define, global) { 'use strict';
!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
("function").should.be.eql("function");
__webpack_require__(/*! ./a */ 2).should.be.eql("a");
return "#138 2.";
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
})(__webpack_require__(/*! !webpack amd define */ 8), this);
module.exports.should.be.eql("#138 2.");
});
it("should parse an define with empty array and object", function() {
var obj = {ok: 95476};
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (obj), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
module.exports.should.be.eql(obj);
});
it("should parse an define with object", function() {
var obj = {ok: 76243};
!(__WEBPACK_AMD_DEFINE_FACTORY__ = (obj), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
module.exports.should.be.eql(obj);
});
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! (webpack)/buildin/module.js */ 9)(module)))
/***/ },
/* 1 */
/*!********************************************!*\
!*** ./parsing/extract-amd/constructor.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function(value) {
this.value = value;
}
/***/ },
/* 2 */
/*!**********************************!*\
!*** ./parsing/extract-amd/a.js ***!
\**********************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = "a";
/***/ },
/* 3 */
/*!*****************************************!*\
!*** ./parsing/extract-amd/circular.js ***!
\*****************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = 1;
module.exports = __webpack_require__(/*! ./circular */ 3);
/***/ },
/* 4 */
/*!*****************************************!*\
!*** ./parsing/extract-amd/optional.js ***!
\*****************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = 2;
try { module.exports.a = __webpack_require__(/*! ./a */ 2); } catch (e) {};
try { module.exports.b = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"./b\""); e.code = 'MODULE_NOT_FOUND'; throw e; }())); } catch (e) {};
/***/ },
/* 5 */,
/* 6 */,
/* 7 */,
/* 8 */
/*!***************************************!*\
!*** (webpack)/buildin/amd-define.js ***!
\***************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function() { throw new Error("define cannot be used indirect"); };
/***/ },
/* 9 */
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ },
/* 10 */,
/* 11 */,
/* 12 */,
/* 13 */
/*!****************************************!*\
!*** (webpack)/~/should/lib/should.js ***!
\****************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ./util */ 14),
AssertionError = util.AssertionError,
inspect = util.inspect;
/**
* Our function should
* @param obj
* @returns {Assertion}
*/
var should = function(obj) {
return new Assertion(util.isWrapperType(obj) ? obj.valueOf() : obj);
};
/**
* Initialize a new `Assertion` with the given _obj_.
*
* @param {*} obj
* @api private
*/
var Assertion = should.Assertion = function Assertion(obj) {
this.obj = obj;
};
/**
Way to extend Assertion function. It uses some logic
to define only positive assertions and itself rule with negative assertion.
All actions happen in subcontext and this method take care about negation.
Potentially we can add some more modifiers that does not depends from state of assertion.
*/
Assertion.add = function(name, f, isGetter) {
var prop = { enumerable: true };
prop[isGetter ? 'get' : 'value'] = function() {
var context = new Assertion(this.obj);
context.copy = context.copyIfMissing;
context.anyOne = this.anyOne;
try {
f.apply(context, arguments);
} catch(e) {
//copy data from sub context to this
this.copy(context);
//check for fail
if(e instanceof should.AssertionError) {
//negative fail
if(this.negate) {
this.obj = context.obj;
this.negate = false;
return this;
}
this.assert(false);
}
// throw if it is another exception
throw e;
}
//copy data from sub context to this
this.copy(context);
if(this.negate) {
this.assert(false);
}
this.obj = context.obj;
this.negate = false;
return this;
};
Object.defineProperty(Assertion.prototype, name, prop);
};
Assertion.alias = function(from, to) {
var desc = Object.getOwnPropertyDescriptor(Assertion.prototype, from);
if(!desc) throw new Error('Alias ' + from + ' -> ' + to + ' could not be created as ' + from + ' not defined');
Object.defineProperty(Assertion.prototype, to, desc);
};
should.AssertionError = AssertionError;
should.format = function (value) {
if(util.isDate(value) && typeof value.inspect !== 'function') return value.toISOString(); //show millis in dates
return inspect(value, { depth: null });
};
should.use = function(f) {
f(this, Assertion);
return this;
};
/**
* Expose should to external world.
*/
exports = module.exports = should;
/**
* Expose api via `Object#should`.
*
* @api public
*/
Object.defineProperty(Object.prototype, 'should', {
set: function() {
},
get: function() {
return should(this);
},
configurable: true
});
Assertion.prototype = {
constructor: Assertion,
assert: function(expr) {
if(expr) return this;
var params = this.params;
var msg = params.message, generatedMessage = false;
if(!msg) {
msg = this.getMessage();
generatedMessage = true;
}
var err = new AssertionError({
message: msg, actual: this.obj, expected: params.expected, stackStartFunction: this.assert
});
err.showDiff = params.showDiff;
err.operator = params.operator;
err.generatedMessage = generatedMessage;
throw err;
},
getMessage: function() {
return 'expected ' + ('obj' in this.params ? this.params.obj: should.format(this.obj)) + (this.negate ? ' not ': ' ') +
this.params.operator + ('expected' in this.params ? ' ' + should.format(this.params.expected) : '');
},
copy: function(other) {
this.params = other.params;
},
copyIfMissing: function(other) {
if(!this.params) this.params = other.params;
},
/**
* Negation modifier.
*
* @api public
*/
get not() {
this.negate = !this.negate;
return this;
},
/**
* Any modifier - it affect on execution of sequenced assertion to do not check all, but any of
*
* @api public
*/
get any() {
this.anyOne = true;
return this;
}
};
should
.use(__webpack_require__(/*! ./ext/assert */ 15))
.use(__webpack_require__(/*! ./ext/chain */ 16))
.use(__webpack_require__(/*! ./ext/bool */ 17))
.use(__webpack_require__(/*! ./ext/number */ 18))
.use(__webpack_require__(/*! ./ext/eql */ 19))
.use(__webpack_require__(/*! ./ext/type */ 20))
.use(__webpack_require__(/*! ./ext/string */ 21))
.use(__webpack_require__(/*! ./ext/property */ 22))
.use(__webpack_require__(/*! ./ext/error */ 23))
.use(__webpack_require__(/*! ./ext/match */ 24))
.use(__webpack_require__(/*! ./ext/contain */ 25));
/***/ },
/* 14 */
/*!**************************************!*\
!*** (webpack)/~/should/lib/util.js ***!
\**************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Check if given obj just a primitive type wrapper
* @param {Object} obj
* @returns {boolean}
* @api private
*/
exports.isWrapperType = function(obj) {
return isNumber(obj) || isString(obj) || isBoolean(obj);
};
/**
* Merge object b with object a.
*
* var a = { foo: 'bar' }
* , b = { bar: 'baz' };
*
* utils.merge(a, b);
* // => { foo: 'bar', bar: 'baz' }
*
* @param {Object} a
* @param {Object} b
* @return {Object}
* @api private
*/
exports.merge = function(a, b){
if (a && b) {
for (var key in b) {
a[key] = b[key];
}
}
return a;
};
function isArray(arr) {
return isObject(arr) && (arr.__ArrayLike || Array.isArray(arr));
}
exports.isArray = isArray;
function isNumber(arg) {
return typeof arg === 'number' || arg instanceof Number;
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string' || arg instanceof String;
}
function isBoolean(arg) {
return typeof arg === 'boolean' || arg instanceof Boolean;
}
exports.isBoolean = isBoolean;
exports.isString = isString;
function isBuffer(arg) {
return typeof Buffer !== 'undefined' && arg instanceof Buffer;
}
exports.isBuffer = isBuffer;
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function objectToString(o) {
return Object.prototype.toString.call(o);
}
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isArguments(object) {
return objectToString(object) === '[object Arguments]';
}
exports.isArguments = isArguments;
exports.isFunction = function(arg) {
return typeof arg === 'function' || arg instanceof Function;
};
function isError(e) {
return (isObject(e) && objectToString(e) === '[object Error]') || (e instanceof Error);
}
exports.isError = isError;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
exports.inspect = __webpack_require__(/*! ./inspect */ 27).inspect;
exports.AssertionError = __webpack_require__(/*! assert */ 26).AssertionError;
var hasOwnProperty = Object.prototype.hasOwnProperty;
exports.forOwn = function(obj, f, context) {
for(var prop in obj) {
if(hasOwnProperty.call(obj, prop)) {
f.call(context, obj[prop], prop);
}
}
};
var functionNameRE = /^\s*function\s*(\S*)\s*\(/;
exports.functionName = function(f) {
if(f.name) {
return f.name;
}
var name = f.toString().match(functionNameRE)[1];
return name;
};
exports.formatProp = function(name) {
name = JSON.stringify('' + name);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'")
.replace(/\\\\/g, '\\');
}
return name;
}
/***/ },
/* 15 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/assert.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 14)
, assert = __webpack_require__(/*! assert */ 26)
, AssertionError = assert.AssertionError;
module.exports = function(should) {
var i = should.format;
/**
* Expose assert to should
*
* This allows you to do things like below
* without require()ing the assert module.
*
* should.equal(foo.bar, undefined);
*
*/
util.merge(should, assert);
/**
* Assert _obj_ exists, with optional message.
*
* @param {*} obj
* @param {String} [msg]
* @api public
*/
should.exist = should.exists = function(obj, msg) {
if(null == obj) {
throw new AssertionError({
message: msg || ('expected ' + i(obj) + ' to exist'), stackStartFunction: should.exist
});
}
};
/**
* Asserts _obj_ does not exist, with optional message.
*
* @param {*} obj
* @param {String} [msg]
* @api public
*/
should.not = {};
should.not.exist = should.not.exists = function(obj, msg) {
if(null != obj) {
throw new AssertionError({
message: msg || ('expected ' + i(obj) + ' to not exist'), stackStartFunction: should.not.exist
});
}
};
};
/***/ },
/* 16 */
/*!*******************************************!*\
!*** (webpack)/~/should/lib/ext/chain.js ***!
\*******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
function addLink(name) {
Object.defineProperty(Assertion.prototype, name, {
get: function() {
return this;
},
enumerable: true
});
}
['an', 'of', 'a', 'and', 'be', 'have', 'with', 'is', 'which', 'the'].forEach(addLink);
};
/***/ },
/* 17 */
/*!******************************************!*\
!*** (webpack)/~/should/lib/ext/bool.js ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('true', function() {
this.is.exactly(true);
}, true);
Assertion.alias('true', 'True');
Assertion.add('false', function() {
this.is.exactly(false);
}, true);
Assertion.alias('false', 'False');
Assertion.add('ok', function() {
this.params = { operator: 'to be truthy' };
this.assert(this.obj);
}, true);
};
/***/ },
/* 18 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/number.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('NaN', function() {
this.params = { operator: 'to be NaN' };
this.assert(this.obj !== this.obj);
}, true);
Assertion.add('Infinity', function() {
this.params = { operator: 'to be Infinity' };
this.is.a.Number
.and.not.a.NaN
.and.assert(!isFinite(this.obj));
}, true);
Assertion.add('within', function(start, finish, description) {
this.params = { operator: 'to be within ' + start + '..' + finish, message: description };
this.assert(this.obj >= start && this.obj <= finish);
});
Assertion.add('approximately', function(value, delta, description) {
this.params = { operator: 'to be approximately ' + value + " ±" + delta, message: description };
this.assert(Math.abs(this.obj - value) <= delta);
});
Assertion.add('above', function(n, description) {
this.params = { operator: 'to be above ' + n, message: description };
this.assert(this.obj > n);
});
Assertion.add('below', function(n, description) {
this.params = { operator: 'to be below ' + n, message: description };
this.assert(this.obj < n);
});
Assertion.alias('above', 'greaterThan');
Assertion.alias('below', 'lessThan');
};
/***/ },
/* 19 */
/*!*****************************************!*\
!*** (webpack)/~/should/lib/ext/eql.js ***!
\*****************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var eql = __webpack_require__(/*! ../eql */ 28);
module.exports = function(should, Assertion) {
Assertion.add('eql', function(val, description) {
this.params = { operator: 'to equal', expected: val, showDiff: true, message: description };
this.assert(eql(val, this.obj));
});
Assertion.add('equal', function(val, description) {
this.params = { operator: 'to be', expected: val, showDiff: true, message: description };
this.assert(val === this.obj);
});
Assertion.alias('equal', 'exactly');
};
/***/ },
/* 20 */
/*!******************************************!*\
!*** (webpack)/~/should/lib/ext/type.js ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 14);
module.exports = function(should, Assertion) {
Assertion.add('Number', function() {
this.params = { operator: 'to be a number' };
this.assert(util.isNumber(this.obj));
}, true);
Assertion.add('arguments', function() {
this.params = { operator: 'to be arguments' };
this.assert(util.isArguments(this.obj));
}, true);
Assertion.add('type', function(type, description) {
this.params = { operator: 'to have type ' + type, message: description };
(typeof this.obj).should.be.exactly(type, description);
});
Assertion.add('instanceof', function(constructor, description) {
this.params = { operator: 'to be an instance of ' + util.functionName(constructor), message: description };
this.assert(Object(this.obj) instanceof constructor);
});
Assertion.add('Function', function() {
this.params = { operator: 'to be a function' };
this.assert(util.isFunction(this.obj));
}, true);
Assertion.add('Object', function() {
this.params = { operator: 'to be an object' };
this.assert(util.isObject(this.obj));
}, true);
Assertion.add('String', function() {
this.params = { operator: 'to be a string' };
this.assert(util.isString(this.obj));
}, true);
Assertion.add('Array', function() {
this.params = { operator: 'to be an array' };
this.assert(util.isArray(this.obj));
}, true);
Assertion.add('Boolean', function() {
this.params = { operator: 'to be a boolean' };
this.assert(util.isBoolean(this.obj));
}, true);
Assertion.add('Error', function() {
this.params = { operator: 'to be an error' };
this.assert(util.isError(this.obj));
}, true);
Assertion.add('null', function() {
this.params = { operator: 'to be null' };
this.assert(this.obj === null);
}, true);
Assertion.alias('null', 'Null');
Assertion.alias('instanceof', 'instanceOf');
};
/***/ },
/* 21 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/string.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('startWith', function(str, description) {
this.params = { operator: 'to start with ' + should.format(str), message: description };
this.assert(0 === this.obj.indexOf(str));
});
Assertion.add('endWith', function(str, description) {
this.params = { operator: 'to end with ' + should.format(str), message: description };
this.assert(this.obj.indexOf(str, this.obj.length - str.length) >= 0);
});
};
/***/ },
/* 22 */
/*!**********************************************!*\
!*** (webpack)/~/should/lib/ext/property.js ***!
\**********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 14),
eql = __webpack_require__(/*! ../eql */ 28);
var aSlice = Array.prototype.slice;
module.exports = function(should, Assertion) {
var i = should.format;
Assertion.add('enumerable', function(name, val) {
name = String(name);
this.params = {
operator:"to have enumerable property " + util.formatProp(name)
};
this.assert(this.obj.propertyIsEnumerable(name));
if(arguments.length > 1){
this.params.operator += " equal to "+i(val);
this.assert(eql(val, this.obj[name]));
}
});
Assertion.add('property', function(name, val) {
name = String(name);
if(arguments.length > 1) {
var p = {};
p[name] = val;
this.have.properties(p);
} else {
this.have.properties(name);
}
this.obj = this.obj[name];
});
Assertion.add('properties', function(names) {
var values = {};
if(arguments.length > 1) {
names = aSlice.call(arguments);
} else if(!util.isArray(names)) {
if(util.isString(names)) {
names = [names];
} else {
values = names;
names = Object.keys(names);
}
}
var obj = Object(this.obj), missingProperties = [];
//just enumerate properties and check if they all present
names.forEach(function(name) {
if(!(name in obj)) missingProperties.push(util.formatProp(name));
});
var props = missingProperties;
if(props.length === 0) {
props = names.map(util.formatProp);
} else if(this.anyOne) {
props = names.filter(function(name) {
return missingProperties.indexOf(util.formatProp(name)) < 0;
}).map(util.formatProp);
}
var operator = (props.length === 1 ?
'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', ');
this.params = { operator: operator };
//check that all properties presented
//or if we request one of them that at least one them presented
this.assert(missingProperties.length === 0 || (this.anyOne && missingProperties.length != names.length));
// check if values in object matched expected
var valueCheckNames = Object.keys(values);
if(valueCheckNames.length) {
var wrongValues = [];
props = [];
// now check values, as there we have all properties
valueCheckNames.forEach(function(name) {
var value = values[name];
if(!eql(obj[name], value)) {
wrongValues.push(util.formatProp(name) + ' of ' + i(value) + ' (got ' + i(obj[name]) + ')');
} else {
props.push(util.formatProp(name) + ' of ' + i(value));
}
});
if((wrongValues.length !== 0 && !this.anyOne) || (this.anyOne && props.length === 0)) {
props = wrongValues;
}
operator = (props.length === 1 ?
'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', ');
this.params = { operator: operator };
//if there is no not matched values
//or there is at least one matched
this.assert(wrongValues.length === 0 || (this.anyOne && wrongValues.length != valueCheckNames.length));
}
});
Assertion.add('length', function(n, description) {
this.have.property('length', n, description);
});
Assertion.alias('length', 'lengthOf');
var hasOwnProperty = Object.prototype.hasOwnProperty;
Assertion.add('ownProperty', function(name, description) {
name = String(name);
this.params = { operator: 'to have own property ' + util.formatProp(name), message: description };
this.assert(hasOwnProperty.call(this.obj, name));
this.obj = this.obj[name];
});
Assertion.alias('ownProperty', 'hasOwnProperty');
Assertion.add('empty', function() {
this.params = { operator: 'to be empty' };
if(util.isString(this.obj) || util.isArray(this.obj) || util.isArguments(this.obj)) {
this.have.property('length', 0);
} else {
var obj = Object(this.obj); // wrap to reference for booleans and numbers
for(var prop in obj) {
this.have.not.ownProperty(prop);
}
}
}, true);
Assertion.add('keys', function(keys) {
if(arguments.length > 1) keys = aSlice.call(arguments);
else if(arguments.length === 1 && util.isString(keys)) keys = [ keys ];
else if(arguments.length === 0) keys = [];
keys = keys.map(String);
var obj = Object(this.obj);
// first check if some keys are missing
var missingKeys = [];
keys.forEach(function(key) {
if(!hasOwnProperty.call(this.obj, key))
missingKeys.push(util.formatProp(key));
}, this);
// second check for extra keys
var extraKeys = [];
Object.keys(obj).forEach(function(key) {
if(keys.indexOf(key) < 0) {
extraKeys.push(util.formatProp(key));
}
});
var verb = keys.length === 0 ? 'to be empty' :
'to have ' + (keys.length === 1 ? 'key ' : 'keys ');
this.params = { operator: verb + keys.map(util.formatProp).join(', ')};
if(missingKeys.length > 0)
this.params.operator += '\n\tmissing keys: ' + missingKeys.join(', ');
if(extraKeys.length > 0)
this.params.operator += '\n\textra keys: ' + extraKeys.join(', ');
this.assert(missingKeys.length === 0 && extraKeys.length === 0);
});
Assertion.alias("keys", "key");
Assertion.add('propertyByPath', function(properties) {
if(arguments.length > 1) properties = aSlice.call(arguments);
else if(arguments.length === 1 && util.isString(properties)) properties = [ properties ];
else if(arguments.length === 0) properties = [];
var allProps = properties.map(util.formatProp);
properties = properties.map(String);
var obj = should(Object(this.obj));
var foundProperties = [];
var currentProperty;
while(currentProperty = properties.shift()) {
this.params = { operator: 'to have property by path ' + allProps.join(', ') + ' - failed on ' + util.formatProp(currentProperty) };
obj = obj.have.property(currentProperty);
foundProperties.push(currentProperty);
}
this.params = { operator: 'to have property by path ' + allProps.join(', ') };
this.obj = obj.obj;
});
};
/***/ },
/* 23 */
/*!*******************************************!*\
!*** (webpack)/~/should/lib/ext/error.js ***!
\*******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 14);
module.exports = function(should, Assertion) {
var i = should.format;
Assertion.add('throw', function(message, properties) {
var fn = this.obj
, err = {}
, errorInfo = ''
, thrown = false;
var errorMatched = true;
try {
fn();
} catch(e) {
thrown = true;
err = e;
}
if(thrown) {
if(message) {
if('string' == typeof message) {
errorMatched = message == err.message;
} else if(message instanceof RegExp) {
errorMatched = message.test(err.message);
} else if('function' == typeof message) {
errorMatched = err instanceof message;
} else if(util.isObject(message)) {
try {
err.should.match(message);
} catch(e) {
if(e instanceof should.AssertionError) {
errorInfo = ": " + e.message;
errorMatched = false;
} else {
throw e;
}
}
}
if(!errorMatched) {
if('string' == typeof message || message instanceof RegExp) {
errorInfo = " with a message matching " + i(message) + ", but got '" + err.message + "'";
} else if('function' == typeof message) {
errorInfo = " of type " + util.functionName(message) + ", but got " + util.functionName(err.constructor);
}
} else if('function' == typeof message && properties) {
try {
err.should.match(properties);
} catch(e) {
if(e instanceof should.AssertionError) {
errorInfo = ": " + e.message;
errorMatched = false;
} else {
throw e;
}
}
}
} else {
errorInfo = " (got " + i(err) + ")";
}
}
this.params = { operator: 'to throw exception' + errorInfo };
this.assert(thrown);
this.assert(errorMatched);
});
Assertion.alias('throw', 'throwError');
};
/***/ },
/* 24 */
/*!*******************************************!*\
!*** (webpack)/~/should/lib/ext/match.js ***!
\*******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 14),
eql = __webpack_require__(/*! ../eql */ 28);
module.exports = function(should, Assertion) {
var i = should.format;
Assertion.add('match', function(other, description) {
this.params = { operator: 'to match ' + i(other), message: description };
if(!eql(this.obj, other)) {
if(util.isRegExp(other)) { // something - regex
if(util.isString(this.obj)) {
this.assert(other.exec(this.obj));
} else if(util.isArray(this.obj)) {
this.obj.forEach(function(item) {
this.assert(other.exec(item));// should we try to convert to String and exec?
}, this);
} else if(util.isObject(this.obj)) {
var notMatchedProps = [], matchedProps = [];
util.forOwn(this.obj, function(value, name) {
if(other.exec(value)) matchedProps.push(util.formatProp(name));
else notMatchedProps.push(util.formatProp(name) + ' (' + i(value) +')');
}, this);
if(notMatchedProps.length)
this.params.operator += '\n\tnot matched properties: ' + notMatchedProps.join(', ');
if(matchedProps.length)
this.params.operator += '\n\tmatched properties: ' + matchedProps.join(', ');
this.assert(notMatchedProps.length == 0);
} // should we try to convert to String and exec?
} else if(util.isFunction(other)) {
var res;
try {
res = other(this.obj);
} catch(e) {
if(e instanceof should.AssertionError) {
this.params.operator += '\n\t' + e.message;
}
throw e;
}
if(res instanceof Assertion) {
this.params.operator += '\n\t' + res.getMessage();
}
//if we throw exception ok - it is used .should inside
if(util.isBoolean(res)) {
this.assert(res); // if it is just boolean function assert on it
}
} else if(util.isObject(other)) { // try to match properties (for Object and Array)
notMatchedProps = []; matchedProps = [];
util.forOwn(other, function(value, key) {
try {
should(this.obj[key]).match(value);
matchedProps.push(util.formatProp(key));
} catch(e) {
if(e instanceof should.AssertionError) {
notMatchedProps.push(util.formatProp(key) + ' (' + i(this.obj[key]) + ')');
} else {
throw e;
}
}
}, this);
if(notMatchedProps.length)
this.params.operator += '\n\tnot matched properties: ' + notMatchedProps.join(', ');
if(matchedProps.length)
this.params.operator += '\n\tmatched properties: ' + matchedProps.join(', ');