Skip to content

Instantly share code, notes, and snippets.

@yields
Created April 2, 2014 05:17
Show Gist options
  • Save yields/9928340 to your computer and use it in GitHub Desktop.
Save yields/9928340 to your computer and use it in GitHub Desktop.
/**
* Require the module at `name`.
*
* @param {String} name
* @return {Object} exports
* @api public
*/
function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
if (module.definition) {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
delete module.definition;
}
return module.exports;
}
/**
* Registered modules.
*/
require.modules = {};
/**
* Register module at `name` with callback `definition`.
*
* @param {String} name
* @param {Function} definition
* @api private
*/
require.register = function (name, definition) {
require.modules[name] = {
definition: definition
};
};
/**
* Define a module's exports immediately with `exports`.
*
* @param {String} name
* @param {Generic} exports
* @api private
*/
require.define = function (name, exports) {
require.modules[name] = {
exports: exports
};
};
require.register("yields~keycode@1.0.0", Function("exports, module",
"\n\
/**\n\
* map\n\
*/\n\
\n\
var map = {\n\
backspace: 8\n\
, tab: 9\n\
, clear: 12\n\
, enter: 13\n\
, shift: 16\n\
, ctrl: 17\n\
, alt: 18\n\
, capslock: 20\n\
, escape: 27\n\
, esc: 27\n\
, space: 32\n\
, left: 37\n\
, up: 38\n\
, right: 39\n\
, down: 40\n\
, del: 46\n\
, comma: 188\n\
, ',': 188\n\
, '.': 190\n\
, '/': 191\n\
, '`': 192\n\
, '-': 189\n\
, '=': 187\n\
, ';': 186\n\
, '[': 219\n\
, '\\\\': 220\n\
, ']': 221\n\
, '\\'': 222\n\
};\n\
\n\
/**\n\
* find a keycode.\n\
*\n\
* @param {String} name\n\
* @return {Number}\n\
*/\n\
\n\
module.exports = function(name){\n\
return map[name] || name.toUpperCase().charCodeAt(0);\n\
};\n\
\n\
//# sourceURL=components/yields/keycode/1.0.0/index.js"
));
require.modules["yields-keycode"] = require.modules["yields~keycode@1.0.0"];
require.modules["yields~keycode"] = require.modules["yields~keycode@1.0.0"];
require.modules["keycode"] = require.modules["yields~keycode@1.0.0"];
require.register("yields~k-sequence@0.1.0", Function("exports, module",
"\n\
/**\n\
* dependencies\n\
*/\n\
\n\
var keycode = require(\"yields~keycode@1.0.0\");\n\
\n\
/**\n\
* Export `sequence`\n\
*/\n\
\n\
module.exports = sequence;\n\
\n\
/**\n\
* Create sequence fn with `keys`.\n\
* optional `ms` which defaults\n\
* to `500ms` and `fn`.\n\
*\n\
* Example:\n\
*\n\
* seq = sequence('a b c', fn);\n\
* el.addEventListener('keydown', seq);\n\
*\n\
* @param {String} keys\n\
* @param {Number} ms\n\
* @param {Function} fn\n\
* @return {Function}\n\
* @api public\n\
*/\n\
\n\
function sequence(keys, ms, fn){\n\
var codes = keys.split(/ +/).map(keycode)\n\
, clen = codes.length\n\
, seq = []\n\
, i = 0\n\
, prev;\n\
\n\
if (2 == arguments.length) {\n\
fn = ms;\n\
ms = 500;\n\
}\n\
\n\
return function(e){\n\
var code = codes[i++];\n\
if (42 != code && code != e.which) return reset();\n\
if (prev && new Date - prev > ms) return reset();\n\
var len = seq.push(e.which);\n\
prev = new Date;\n\
if (len != clen) return;\n\
reset();\n\
fn(e);\n\
};\n\
\n\
function reset(){\n\
prev = null;\n\
seq = [];\n\
i = 0;\n\
}\n\
};\n\
\n\
//# sourceURL=components/yields/k-sequence/0.1.0/index.js"
));
require.modules["yields-k-sequence"] = require.modules["yields~k-sequence@0.1.0"];
require.modules["yields~k-sequence"] = require.modules["yields~k-sequence@0.1.0"];
require.modules["k-sequence"] = require.modules["yields~k-sequence@0.1.0"];
require.register("component~event@0.1.3", Function("exports, module",
"var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',\n\
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',\n\
prefix = bind !== 'addEventListener' ? 'on' : '';\n\
\n\
/**\n\
* Bind `el` event `type` to `fn`.\n\
*\n\
* @param {Element} el\n\
* @param {String} type\n\
* @param {Function} fn\n\
* @param {Boolean} capture\n\
* @return {Function}\n\
* @api public\n\
*/\n\
\n\
exports.bind = function(el, type, fn, capture){\n\
el[bind](prefix + type, fn, capture || false);\n\
return fn;\n\
};\n\
\n\
/**\n\
* Unbind `el` event `type`'s callback `fn`.\n\
*\n\
* @param {Element} el\n\
* @param {String} type\n\
* @param {Function} fn\n\
* @param {Boolean} capture\n\
* @return {Function}\n\
* @api public\n\
*/\n\
\n\
exports.unbind = function(el, type, fn, capture){\n\
el[unbind](prefix + type, fn, capture || false);\n\
return fn;\n\
};\n\
//# sourceURL=components/component/event/0.1.3/index.js"
));
require.modules["component-event"] = require.modules["component~event@0.1.3"];
require.modules["component~event"] = require.modules["component~event@0.1.3"];
require.modules["event"] = require.modules["component~event@0.1.3"];
require.register("component~bind@0.0.1", Function("exports, module",
"\n\
//# sourceURL=components/component/bind/0.0.1/index.js"
));
require.modules["component-bind"] = require.modules["component~bind@0.0.1"];
require.modules["component~bind"] = require.modules["component~bind@0.0.1"];
require.modules["bind"] = require.modules["component~bind@0.0.1"];
require.register("component~os@0.0.1", Function("exports, module",
"\n\
\n\
module.exports = os();\n\
\n\
function os() {\n\
var ua = navigator.userAgent;\n\
if (/mac/i.test(ua)) return 'mac';\n\
if (/win/i.test(ua)) return 'windows';\n\
if (/linux/i.test(ua)) return 'linux';\n\
}\n\
\n\
//# sourceURL=components/component/os/0.0.1/index.js"
));
require.modules["component-os"] = require.modules["component~os@0.0.1"];
require.modules["component~os"] = require.modules["component~os@0.0.1"];
require.modules["os"] = require.modules["component~os@0.0.1"];
require.register("component~stack@master", Function("exports, module",
"\n\
/**\n\
* Expose `stack()`.\n\
*/\n\
\n\
module.exports = stack;\n\
\n\
/**\n\
* Return the stack.\n\
*\n\
* @return {Array}\n\
* @api public\n\
*/\n\
\n\
function stack() {\n\
var orig = Error.prepareStackTrace;\n\
Error.prepareStackTrace = function(_, stack){ return stack; };\n\
var err = new Error;\n\
Error.captureStackTrace(err, arguments.callee);\n\
var stack = err.stack;\n\
Error.prepareStackTrace = orig;\n\
return stack;\n\
}\n\
//# sourceURL=components/component/stack/master/index.js"
));
require.modules["component-stack"] = require.modules["component~stack@master"];
require.modules["component~stack"] = require.modules["component~stack@master"];
require.modules["stack"] = require.modules["component~stack@master"];
require.register("jkroso~type@1.1.0", Function("exports, module",
"\n\
var toString = {}.toString\n\
var DomNode = typeof window != 'undefined'\n\
? window.Node\n\
: Function\n\
\n\
/**\n\
* Return the type of `val`.\n\
*\n\
* @param {Mixed} val\n\
* @return {String}\n\
* @api public\n\
*/\n\
\n\
module.exports = exports = function(x){\n\
var type = typeof x\n\
if (type != 'object') return type\n\
type = types[toString.call(x)]\n\
if (type) return type\n\
if (x instanceof DomNode) switch (x.nodeType) {\n\
case 1: return 'element'\n\
case 3: return 'text-node'\n\
case 9: return 'document'\n\
case 11: return 'document-fragment'\n\
default: return 'dom-node'\n\
}\n\
}\n\
\n\
var types = exports.types = {\n\
'[object Function]': 'function',\n\
'[object Date]': 'date',\n\
'[object RegExp]': 'regexp',\n\
'[object Arguments]': 'arguments',\n\
'[object Array]': 'array',\n\
'[object String]': 'string',\n\
'[object Null]': 'null',\n\
'[object Undefined]': 'undefined',\n\
'[object Number]': 'number',\n\
'[object Boolean]': 'boolean',\n\
'[object Object]': 'object',\n\
'[object Text]': 'text-node',\n\
'[object Uint8Array]': 'bit-array',\n\
'[object Uint16Array]': 'bit-array',\n\
'[object Uint32Array]': 'bit-array',\n\
'[object Uint8ClampedArray]': 'bit-array',\n\
'[object Error]': 'error',\n\
'[object FormData]': 'form-data',\n\
'[object File]': 'file',\n\
'[object Blob]': 'blob'\n\
}\n\
\n\
//# sourceURL=components/jkroso/type/1.1.0/index.js"
));
require.modules["jkroso-type"] = require.modules["jkroso~type@1.1.0"];
require.modules["jkroso~type"] = require.modules["jkroso~type@1.1.0"];
require.modules["type"] = require.modules["jkroso~type@1.1.0"];
require.register("jkroso~equals@0.3.6", Function("exports, module",
"\n\
var type = require(\"jkroso~type@1.1.0\")\n\
\n\
/**\n\
* expose equals\n\
*/\n\
\n\
module.exports = equals\n\
equals.compare = compare\n\
\n\
/**\n\
* assert all values are equal\n\
*\n\
* @param {Any} [...]\n\
* @return {Boolean}\n\
*/\n\
\n\
function equals(){\n\
var i = arguments.length - 1\n\
while (i > 0) {\n\
if (!compare(arguments[i], arguments[--i])) return false\n\
}\n\
return true\n\
}\n\
\n\
// (any, any, [array]) -> boolean\n\
function compare(a, b, memos){\n\
// All identical values are equivalent\n\
if (a === b) return true\n\
var fnA = types[type(a)]\n\
var fnB = types[type(b)]\n\
return fnA && fnA === fnB\n\
? fnA(a, b, memos)\n\
: false\n\
}\n\
\n\
var types = {}\n\
\n\
// (Number) -> boolean\n\
types.number = function(a){\n\
// NaN check\n\
return a !== a\n\
}\n\
\n\
// (function, function, array) -> boolean\n\
types['function'] = function(a, b, memos){\n\
return a.toString() === b.toString()\n\
// Functions can act as objects\n\
&& types.object(a, b, memos)\n\
&& compare(a.prototype, b.prototype)\n\
}\n\
\n\
// (date, date) -> boolean\n\
types.date = function(a, b){\n\
return +a === +b\n\
}\n\
\n\
// (regexp, regexp) -> boolean\n\
types.regexp = function(a, b){\n\
return a.toString() === b.toString()\n\
}\n\
\n\
// (DOMElement, DOMElement) -> boolean\n\
types.element = function(a, b){\n\
return a.outerHTML === b.outerHTML\n\
}\n\
\n\
// (textnode, textnode) -> boolean\n\
types.textnode = function(a, b){\n\
return a.textContent === b.textContent\n\
}\n\
\n\
// decorate `fn` to prevent it re-checking objects\n\
// (function) -> function\n\
function memoGaurd(fn){\n\
return function(a, b, memos){\n\
if (!memos) return fn(a, b, [])\n\
var i = memos.length, memo\n\
while (memo = memos[--i]) {\n\
if (memo[0] === a && memo[1] === b) return true\n\
}\n\
return fn(a, b, memos)\n\
}\n\
}\n\
\n\
types['arguments'] =\n\
types.array = memoGaurd(compareArrays)\n\
\n\
// (array, array, array) -> boolean\n\
function compareArrays(a, b, memos){\n\
var i = a.length\n\
if (i !== b.length) return false\n\
memos.push([a, b])\n\
while (i--) {\n\
if (!compare(a[i], b[i], memos)) return false\n\
}\n\
return true\n\
}\n\
\n\
types.object = memoGaurd(compareObjects)\n\
\n\
// (object, object, array) -> boolean\n\
function compareObjects(a, b, memos) {\n\
var ka = getEnumerableProperties(a)\n\
var kb = getEnumerableProperties(b)\n\
var i = ka.length\n\
\n\
// same number of properties\n\
if (i !== kb.length) return false\n\
\n\
// although not necessarily the same order\n\
ka.sort()\n\
kb.sort()\n\
\n\
// cheap key test\n\
while (i--) if (ka[i] !== kb[i]) return false\n\
\n\
// remember\n\
memos.push([a, b])\n\
\n\
// iterate again this time doing a thorough check\n\
i = ka.length\n\
while (i--) {\n\
var key = ka[i]\n\
if (!compare(a[key], b[key], memos)) return false\n\
}\n\
\n\
return true\n\
}\n\
\n\
// (object) -> array\n\
function getEnumerableProperties (object) {\n\
var result = []\n\
for (var k in object) if (k !== 'constructor') {\n\
result.push(k)\n\
}\n\
return result\n\
}\n\
\n\
//# sourceURL=components/jkroso/equals/0.3.6/index.js"
));
require.modules["jkroso-equals"] = require.modules["jkroso~equals@0.3.6"];
require.modules["jkroso~equals"] = require.modules["jkroso~equals@0.3.6"];
require.modules["equals"] = require.modules["jkroso~equals@0.3.6"];
require.register("component~assert@0.3.0", Function("exports, module",
"\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var stack = require(\"component~stack@master\");\n\
var equals = require(\"jkroso~equals@0.3.6\");\n\
\n\
/**\n\
* Assert `expr` with optional failure `msg`.\n\
*\n\
* @param {Mixed} expr\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
module.exports = exports = function (expr, msg) {\n\
if (expr) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is weak equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.equal = function (actual, expected, msg) {\n\
if (actual == expected) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is not weak equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.notEqual = function (actual, expected, msg) {\n\
if (actual != expected) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is deep equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.deepEqual = function (actual, expected, msg) {\n\
if (equals(actual, expected)) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is not deep equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.notDeepEqual = function (actual, expected, msg) {\n\
if (!equals(actual, expected)) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is strict equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.strictEqual = function (actual, expected, msg) {\n\
if (actual === expected) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `actual` is not strict equal to `expected`.\n\
*\n\
* @param {Mixed} actual\n\
* @param {Mixed} expected\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.notStrictEqual = function (actual, expected, msg) {\n\
if (actual !== expected) return;\n\
throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `block` throws an `error`.\n\
*\n\
* @param {Function} block\n\
* @param {Function} [error]\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.throws = function (block, error, msg) {\n\
var err;\n\
try {\n\
block();\n\
} catch (e) {\n\
err = e;\n\
}\n\
if (!err) throw new Error(message());\n\
if (error && !(err instanceof error)) throw new Error(message());\n\
};\n\
\n\
/**\n\
* Assert `block` doesn't throw an `error`.\n\
*\n\
* @param {Function} block\n\
* @param {Function} [error]\n\
* @param {String} [msg]\n\
* @api public\n\
*/\n\
\n\
exports.doesNotThrow = function (block, error, msg) {\n\
var err;\n\
try {\n\
block();\n\
} catch (e) {\n\
err = e;\n\
}\n\
if (error && (err instanceof error)) throw new Error(message());\n\
if (err) throw new Error(message());\n\
};\n\
\n\
/**\n\
* Create a message from the call stack.\n\
*\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function message() {\n\
if (!Error.captureStackTrace) return 'assertion failed';\n\
var callsite = stack()[2];\n\
var fn = callsite.getFunctionName();\n\
var file = callsite.getFileName();\n\
var line = callsite.getLineNumber() - 1;\n\
var col = callsite.getColumnNumber() - 1;\n\
var src = getScript(file);\n\
line = src.split('\\n\
')[line].slice(col);\n\
return line.match(/assert\\((.*)\\)/)[1].trim();\n\
}\n\
\n\
/**\n\
* Load contents of `script`.\n\
*\n\
* @param {String} script\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function getScript(script) {\n\
var xhr = new XMLHttpRequest;\n\
xhr.open('GET', script, false);\n\
xhr.send(null);\n\
return xhr.responseText;\n\
}\n\
//# sourceURL=components/component/assert/0.3.0/index.js"
));
require.modules["component-assert"] = require.modules["component~assert@0.3.0"];
require.modules["component~assert"] = require.modules["component~assert@0.3.0"];
require.modules["assert"] = require.modules["component~assert@0.3.0"];
require.register("visionmedia~mocha@1.18.2", Function("exports, module",
";(function(){\n\
\n\
// CommonJS require()\n\
\n\
function require(p){\n\
var path = require.resolve(p)\n\
, mod = require.modules[path];\n\
if (!mod) throw new Error('failed to require \"' + p + '\"');\n\
if (!mod.exports) {\n\
mod.exports = {};\n\
mod.call(mod.exports, mod, mod.exports, require.relative(path));\n\
}\n\
return mod.exports;\n\
}\n\
\n\
require.modules = {};\n\
\n\
require.resolve = function (path){\n\
var orig = path\n\
, reg = path + '.js'\n\
, index = path + '/index.js';\n\
return require.modules[reg] && reg\n\
|| require.modules[index] && index\n\
|| orig;\n\
};\n\
\n\
require.register = function (path, fn){\n\
require.modules[path] = fn;\n\
};\n\
\n\
require.relative = function (parent) {\n\
return function(p){\n\
if ('.' != p.charAt(0)) return require(p);\n\
\n\
var path = parent.split('/')\n\
, segs = p.split('/');\n\
path.pop();\n\
\n\
for (var i = 0; i < segs.length; i++) {\n\
var seg = segs[i];\n\
if ('..' == seg) path.pop();\n\
else if ('.' != seg) path.push(seg);\n\
}\n\
\n\
return require(path.join('/'));\n\
};\n\
};\n\
\n\
\n\
require.register(\"browser/debug.js\", function(module, exports, require){\n\
\n\
module.exports = function(type){\n\
return function(){\n\
}\n\
};\n\
\n\
}); // module: browser/debug.js\n\
\n\
require.register(\"browser/diff.js\", function(module, exports, require){\n\
/* See LICENSE file for terms of use */\n\
\n\
/*\n\
* Text diff implementation.\n\
*\n\
* This library supports the following APIS:\n\
* JsDiff.diffChars: Character by character diff\n\
* JsDiff.diffWords: Word (as defined by \\b regex) diff which ignores whitespace\n\
* JsDiff.diffLines: Line based diff\n\
*\n\
* JsDiff.diffCss: Diff targeted at CSS content\n\
*\n\
* These methods are based on the implementation proposed in\n\
* \"An O(ND) Difference Algorithm and its Variations\" (Myers, 1986).\n\
* http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927\n\
*/\n\
var JsDiff = (function() {\n\
/*jshint maxparams: 5*/\n\
function clonePath(path) {\n\
return { newPos: path.newPos, components: path.components.slice(0) };\n\
}\n\
function removeEmpty(array) {\n\
var ret = [];\n\
for (var i = 0; i < array.length; i++) {\n\
if (array[i]) {\n\
ret.push(array[i]);\n\
}\n\
}\n\
return ret;\n\
}\n\
function escapeHTML(s) {\n\
var n = s;\n\
n = n.replace(/&/g, '&amp;');\n\
n = n.replace(/</g, '&lt;');\n\
n = n.replace(/>/g, '&gt;');\n\
n = n.replace(/\"/g, '&quot;');\n\
\n\
return n;\n\
}\n\
\n\
var Diff = function(ignoreWhitespace) {\n\
this.ignoreWhitespace = ignoreWhitespace;\n\
};\n\
Diff.prototype = {\n\
diff: function(oldString, newString) {\n\
// Handle the identity case (this is due to unrolling editLength == 0\n\
if (newString === oldString) {\n\
return [{ value: newString }];\n\
}\n\
if (!newString) {\n\
return [{ value: oldString, removed: true }];\n\
}\n\
if (!oldString) {\n\
return [{ value: newString, added: true }];\n\
}\n\
\n\
newString = this.tokenize(newString);\n\
oldString = this.tokenize(oldString);\n\
\n\
var newLen = newString.length, oldLen = oldString.length;\n\
var maxEditLength = newLen + oldLen;\n\
var bestPath = [{ newPos: -1, components: [] }];\n\
\n\
// Seed editLength = 0\n\
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);\n\
if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) {\n\
return bestPath[0].components;\n\
}\n\
\n\
for (var editLength = 1; editLength <= maxEditLength; editLength++) {\n\
for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) {\n\
var basePath;\n\
var addPath = bestPath[diagonalPath-1],\n\
removePath = bestPath[diagonalPath+1];\n\
oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;\n\
if (addPath) {\n\
// No one else is going to attempt to use this value, clear it\n\
bestPath[diagonalPath-1] = undefined;\n\
}\n\
\n\
var canAdd = addPath && addPath.newPos+1 < newLen;\n\
var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;\n\
if (!canAdd && !canRemove) {\n\
bestPath[diagonalPath] = undefined;\n\
continue;\n\
}\n\
\n\
// Select the diagonal that we want to branch from. We select the prior\n\
// path whose position in the new string is the farthest from the origin\n\
// and does not pass the bounds of the diff graph\n\
if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {\n\
basePath = clonePath(removePath);\n\
this.pushComponent(basePath.components, oldString[oldPos], undefined, true);\n\
} else {\n\
basePath = clonePath(addPath);\n\
basePath.newPos++;\n\
this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);\n\
}\n\
\n\
var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);\n\
\n\
if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) {\n\
return basePath.components;\n\
} else {\n\
bestPath[diagonalPath] = basePath;\n\
}\n\
}\n\
}\n\
},\n\
\n\
pushComponent: function(components, value, added, removed) {\n\
var last = components[components.length-1];\n\
if (last && last.added === added && last.removed === removed) {\n\
// We need to clone here as the component clone operation is just\n\
// as shallow array clone\n\
components[components.length-1] =\n\
{value: this.join(last.value, value), added: added, removed: removed };\n\
} else {\n\
components.push({value: value, added: added, removed: removed });\n\
}\n\
},\n\
extractCommon: function(basePath, newString, oldString, diagonalPath) {\n\
var newLen = newString.length,\n\
oldLen = oldString.length,\n\
newPos = basePath.newPos,\n\
oldPos = newPos - diagonalPath;\n\
while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) {\n\
newPos++;\n\
oldPos++;\n\
\n\
this.pushComponent(basePath.components, newString[newPos], undefined, undefined);\n\
}\n\
basePath.newPos = newPos;\n\
return oldPos;\n\
},\n\
\n\
equals: function(left, right) {\n\
var reWhitespace = /\\S/;\n\
if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) {\n\
return true;\n\
} else {\n\
return left === right;\n\
}\n\
},\n\
join: function(left, right) {\n\
return left + right;\n\
},\n\
tokenize: function(value) {\n\
return value;\n\
}\n\
};\n\
\n\
var CharDiff = new Diff();\n\
\n\
var WordDiff = new Diff(true);\n\
var WordWithSpaceDiff = new Diff();\n\
WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {\n\
return removeEmpty(value.split(/(\\s+|\\b)/));\n\
};\n\
\n\
var CssDiff = new Diff(true);\n\
CssDiff.tokenize = function(value) {\n\
return removeEmpty(value.split(/([{}:;,]|\\s+)/));\n\
};\n\
\n\
var LineDiff = new Diff();\n\
LineDiff.tokenize = function(value) {\n\
return value.split(/^/m);\n\
};\n\
\n\
return {\n\
Diff: Diff,\n\
\n\
diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); },\n\
diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); },\n\
diffWordsWithSpace: function(oldStr, newStr) { return WordWithSpaceDiff.diff(oldStr, newStr); },\n\
diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); },\n\
\n\
diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); },\n\
\n\
createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {\n\
var ret = [];\n\
\n\
ret.push('Index: ' + fileName);\n\
ret.push('===================================================================');\n\
ret.push('--- ' + fileName + (typeof oldHeader === 'undefined' ? '' : '\\t' + oldHeader));\n\
ret.push('+++ ' + fileName + (typeof newHeader === 'undefined' ? '' : '\\t' + newHeader));\n\
\n\
var diff = LineDiff.diff(oldStr, newStr);\n\
if (!diff[diff.length-1].value) {\n\
diff.pop(); // Remove trailing newline add\n\
}\n\
diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier\n\
\n\
function contextLines(lines) {\n\
return lines.map(function(entry) { return ' ' + entry; });\n\
}\n\
function eofNL(curRange, i, current) {\n\
var last = diff[diff.length-2],\n\
isLast = i === diff.length-2,\n\
isLastOfType = i === diff.length-3 && (current.added !== last.added || current.removed !== last.removed);\n\
\n\
// Figure out if this is the last line for the given file and missing NL\n\
if (!/\\n\
$/.test(current.value) && (isLast || isLastOfType)) {\n\
curRange.push('\\\\ No newline at end of file');\n\
}\n\
}\n\
\n\
var oldRangeStart = 0, newRangeStart = 0, curRange = [],\n\
oldLine = 1, newLine = 1;\n\
for (var i = 0; i < diff.length; i++) {\n\
var current = diff[i],\n\
lines = current.lines || current.value.replace(/\\n\
$/, '').split('\\n\
');\n\
current.lines = lines;\n\
\n\
if (current.added || current.removed) {\n\
if (!oldRangeStart) {\n\
var prev = diff[i-1];\n\
oldRangeStart = oldLine;\n\
newRangeStart = newLine;\n\
\n\
if (prev) {\n\
curRange = contextLines(prev.lines.slice(-4));\n\
oldRangeStart -= curRange.length;\n\
newRangeStart -= curRange.length;\n\
}\n\
}\n\
curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?'+':'-') + entry; }));\n\
eofNL(curRange, i, current);\n\
\n\
if (current.added) {\n\
newLine += lines.length;\n\
} else {\n\
oldLine += lines.length;\n\
}\n\
} else {\n\
if (oldRangeStart) {\n\
// Close out any changes that have been output (or join overlapping)\n\
if (lines.length <= 8 && i < diff.length-2) {\n\
// Overlapping\n\
curRange.push.apply(curRange, contextLines(lines));\n\
} else {\n\
// end the range and output\n\
var contextSize = Math.min(lines.length, 4);\n\
ret.push(\n\
'@@ -' + oldRangeStart + ',' + (oldLine-oldRangeStart+contextSize)\n\
+ ' +' + newRangeStart + ',' + (newLine-newRangeStart+contextSize)\n\
+ ' @@');\n\
ret.push.apply(ret, curRange);\n\
ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));\n\
if (lines.length <= 4) {\n\
eofNL(ret, i, current);\n\
}\n\
\n\
oldRangeStart = 0; newRangeStart = 0; curRange = [];\n\
}\n\
}\n\
oldLine += lines.length;\n\
newLine += lines.length;\n\
}\n\
}\n\
\n\
return ret.join('\\n\
') + '\\n\
';\n\
},\n\
\n\
applyPatch: function(oldStr, uniDiff) {\n\
var diffstr = uniDiff.split('\\n\
');\n\
var diff = [];\n\
var remEOFNL = false,\n\
addEOFNL = false;\n\
\n\
for (var i = (diffstr[0][0]==='I'?4:0); i < diffstr.length; i++) {\n\
if(diffstr[i][0] === '@') {\n\
var meh = diffstr[i].split(/@@ -(\\d+),(\\d+) \\+(\\d+),(\\d+) @@/);\n\
diff.unshift({\n\
start:meh[3],\n\
oldlength:meh[2],\n\
oldlines:[],\n\
newlength:meh[4],\n\
newlines:[]\n\
});\n\
} else if(diffstr[i][0] === '+') {\n\
diff[0].newlines.push(diffstr[i].substr(1));\n\
} else if(diffstr[i][0] === '-') {\n\
diff[0].oldlines.push(diffstr[i].substr(1));\n\
} else if(diffstr[i][0] === ' ') {\n\
diff[0].newlines.push(diffstr[i].substr(1));\n\
diff[0].oldlines.push(diffstr[i].substr(1));\n\
} else if(diffstr[i][0] === '\\\\') {\n\
if (diffstr[i-1][0] === '+') {\n\
remEOFNL = true;\n\
} else if(diffstr[i-1][0] === '-') {\n\
addEOFNL = true;\n\
}\n\
}\n\
}\n\
\n\
var str = oldStr.split('\\n\
');\n\
for (var i = diff.length - 1; i >= 0; i--) {\n\
var d = diff[i];\n\
for (var j = 0; j < d.oldlength; j++) {\n\
if(str[d.start-1+j] !== d.oldlines[j]) {\n\
return false;\n\
}\n\
}\n\
Array.prototype.splice.apply(str,[d.start-1,+d.oldlength].concat(d.newlines));\n\
}\n\
\n\
if (remEOFNL) {\n\
while (!str[str.length-1]) {\n\
str.pop();\n\
}\n\
} else if (addEOFNL) {\n\
str.push('');\n\
}\n\
return str.join('\\n\
');\n\
},\n\
\n\
convertChangesToXML: function(changes){\n\
var ret = [];\n\
for ( var i = 0; i < changes.length; i++) {\n\
var change = changes[i];\n\
if (change.added) {\n\
ret.push('<ins>');\n\
} else if (change.removed) {\n\
ret.push('<del>');\n\
}\n\
\n\
ret.push(escapeHTML(change.value));\n\
\n\
if (change.added) {\n\
ret.push('</ins>');\n\
} else if (change.removed) {\n\
ret.push('</del>');\n\
}\n\
}\n\
return ret.join('');\n\
},\n\
\n\
// See: http://code.google.com/p/google-diff-match-patch/wiki/API\n\
convertChangesToDMP: function(changes){\n\
var ret = [], change;\n\
for ( var i = 0; i < changes.length; i++) {\n\
change = changes[i];\n\
ret.push([(change.added ? 1 : change.removed ? -1 : 0), change.value]);\n\
}\n\
return ret;\n\
}\n\
};\n\
})();\n\
\n\
if (typeof module !== 'undefined') {\n\
module.exports = JsDiff;\n\
}\n\
\n\
}); // module: browser/diff.js\n\
\n\
require.register(\"browser/events.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module exports.\n\
*/\n\
\n\
exports.EventEmitter = EventEmitter;\n\
\n\
/**\n\
* Check if `obj` is an array.\n\
*/\n\
\n\
function isArray(obj) {\n\
return '[object Array]' == {}.toString.call(obj);\n\
}\n\
\n\
/**\n\
* Event emitter constructor.\n\
*\n\
* @api public\n\
*/\n\
\n\
function EventEmitter(){};\n\
\n\
/**\n\
* Adds a listener.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.on = function (name, fn) {\n\
if (!this.$events) {\n\
this.$events = {};\n\
}\n\
\n\
if (!this.$events[name]) {\n\
this.$events[name] = fn;\n\
} else if (isArray(this.$events[name])) {\n\
this.$events[name].push(fn);\n\
} else {\n\
this.$events[name] = [this.$events[name], fn];\n\
}\n\
\n\
return this;\n\
};\n\
\n\
EventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\
\n\
/**\n\
* Adds a volatile listener.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.once = function (name, fn) {\n\
var self = this;\n\
\n\
function on () {\n\
self.removeListener(name, on);\n\
fn.apply(this, arguments);\n\
};\n\
\n\
on.listener = fn;\n\
this.on(name, on);\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Removes a listener.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.removeListener = function (name, fn) {\n\
if (this.$events && this.$events[name]) {\n\
var list = this.$events[name];\n\
\n\
if (isArray(list)) {\n\
var pos = -1;\n\
\n\
for (var i = 0, l = list.length; i < l; i++) {\n\
if (list[i] === fn || (list[i].listener && list[i].listener === fn)) {\n\
pos = i;\n\
break;\n\
}\n\
}\n\
\n\
if (pos < 0) {\n\
return this;\n\
}\n\
\n\
list.splice(pos, 1);\n\
\n\
if (!list.length) {\n\
delete this.$events[name];\n\
}\n\
} else if (list === fn || (list.listener && list.listener === fn)) {\n\
delete this.$events[name];\n\
}\n\
}\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Removes all listeners for an event.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.removeAllListeners = function (name) {\n\
if (name === undefined) {\n\
this.$events = {};\n\
return this;\n\
}\n\
\n\
if (this.$events && this.$events[name]) {\n\
this.$events[name] = null;\n\
}\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Gets all listeners for a certain event.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.listeners = function (name) {\n\
if (!this.$events) {\n\
this.$events = {};\n\
}\n\
\n\
if (!this.$events[name]) {\n\
this.$events[name] = [];\n\
}\n\
\n\
if (!isArray(this.$events[name])) {\n\
this.$events[name] = [this.$events[name]];\n\
}\n\
\n\
return this.$events[name];\n\
};\n\
\n\
/**\n\
* Emits an event.\n\
*\n\
* @api public\n\
*/\n\
\n\
EventEmitter.prototype.emit = function (name) {\n\
if (!this.$events) {\n\
return false;\n\
}\n\
\n\
var handler = this.$events[name];\n\
\n\
if (!handler) {\n\
return false;\n\
}\n\
\n\
var args = [].slice.call(arguments, 1);\n\
\n\
if ('function' == typeof handler) {\n\
handler.apply(this, args);\n\
} else if (isArray(handler)) {\n\
var listeners = handler.slice();\n\
\n\
for (var i = 0, l = listeners.length; i < l; i++) {\n\
listeners[i].apply(this, args);\n\
}\n\
} else {\n\
return false;\n\
}\n\
\n\
return true;\n\
};\n\
}); // module: browser/events.js\n\
\n\
require.register(\"browser/fs.js\", function(module, exports, require){\n\
\n\
}); // module: browser/fs.js\n\
\n\
require.register(\"browser/path.js\", function(module, exports, require){\n\
\n\
}); // module: browser/path.js\n\
\n\
require.register(\"browser/progress.js\", function(module, exports, require){\n\
/**\n\
* Expose `Progress`.\n\
*/\n\
\n\
module.exports = Progress;\n\
\n\
/**\n\
* Initialize a new `Progress` indicator.\n\
*/\n\
\n\
function Progress() {\n\
this.percent = 0;\n\
this.size(0);\n\
this.fontSize(11);\n\
this.font('helvetica, arial, sans-serif');\n\
}\n\
\n\
/**\n\
* Set progress size to `n`.\n\
*\n\
* @param {Number} n\n\
* @return {Progress} for chaining\n\
* @api public\n\
*/\n\
\n\
Progress.prototype.size = function(n){\n\
this._size = n;\n\
return this;\n\
};\n\
\n\
/**\n\
* Set text to `str`.\n\
*\n\
* @param {String} str\n\
* @return {Progress} for chaining\n\
* @api public\n\
*/\n\
\n\
Progress.prototype.text = function(str){\n\
this._text = str;\n\
return this;\n\
};\n\
\n\
/**\n\
* Set font size to `n`.\n\
*\n\
* @param {Number} n\n\
* @return {Progress} for chaining\n\
* @api public\n\
*/\n\
\n\
Progress.prototype.fontSize = function(n){\n\
this._fontSize = n;\n\
return this;\n\
};\n\
\n\
/**\n\
* Set font `family`.\n\
*\n\
* @param {String} family\n\
* @return {Progress} for chaining\n\
*/\n\
\n\
Progress.prototype.font = function(family){\n\
this._font = family;\n\
return this;\n\
};\n\
\n\
/**\n\
* Update percentage to `n`.\n\
*\n\
* @param {Number} n\n\
* @return {Progress} for chaining\n\
*/\n\
\n\
Progress.prototype.update = function(n){\n\
this.percent = n;\n\
return this;\n\
};\n\
\n\
/**\n\
* Draw on `ctx`.\n\
*\n\
* @param {CanvasRenderingContext2d} ctx\n\
* @return {Progress} for chaining\n\
*/\n\
\n\
Progress.prototype.draw = function(ctx){\n\
try {\n\
var percent = Math.min(this.percent, 100)\n\
, size = this._size\n\
, half = size / 2\n\
, x = half\n\
, y = half\n\
, rad = half - 1\n\
, fontSize = this._fontSize;\n\
\n\
ctx.font = fontSize + 'px ' + this._font;\n\
\n\
var angle = Math.PI * 2 * (percent / 100);\n\
ctx.clearRect(0, 0, size, size);\n\
\n\
// outer circle\n\
ctx.strokeStyle = '#9f9f9f';\n\
ctx.beginPath();\n\
ctx.arc(x, y, rad, 0, angle, false);\n\
ctx.stroke();\n\
\n\
// inner circle\n\
ctx.strokeStyle = '#eee';\n\
ctx.beginPath();\n\
ctx.arc(x, y, rad - 1, 0, angle, true);\n\
ctx.stroke();\n\
\n\
// text\n\
var text = this._text || (percent | 0) + '%'\n\
, w = ctx.measureText(text).width;\n\
\n\
ctx.fillText(\n\
text\n\
, x - w / 2 + 1\n\
, y + fontSize / 2 - 1);\n\
} catch (ex) {} //don't fail if we can't render progress\n\
return this;\n\
};\n\
\n\
}); // module: browser/progress.js\n\
\n\
require.register(\"browser/tty.js\", function(module, exports, require){\n\
\n\
exports.isatty = function(){\n\
return true;\n\
};\n\
\n\
exports.getWindowSize = function(){\n\
if ('innerHeight' in global) {\n\
return [global.innerHeight, global.innerWidth];\n\
} else {\n\
// In a Web Worker, the DOM Window is not available.\n\
return [640, 480];\n\
}\n\
};\n\
\n\
}); // module: browser/tty.js\n\
\n\
require.register(\"context.js\", function(module, exports, require){\n\
\n\
/**\n\
* Expose `Context`.\n\
*/\n\
\n\
module.exports = Context;\n\
\n\
/**\n\
* Initialize a new `Context`.\n\
*\n\
* @api private\n\
*/\n\
\n\
function Context(){}\n\
\n\
/**\n\
* Set or get the context `Runnable` to `runnable`.\n\
*\n\
* @param {Runnable} runnable\n\
* @return {Context}\n\
* @api private\n\
*/\n\
\n\
Context.prototype.runnable = function(runnable){\n\
if (0 == arguments.length) return this._runnable;\n\
this.test = this._runnable = runnable;\n\
return this;\n\
};\n\
\n\
/**\n\
* Set test timeout `ms`.\n\
*\n\
* @param {Number} ms\n\
* @return {Context} self\n\
* @api private\n\
*/\n\
\n\
Context.prototype.timeout = function(ms){\n\
this.runnable().timeout(ms);\n\
return this;\n\
};\n\
\n\
/**\n\
* Set test slowness threshold `ms`.\n\
*\n\
* @param {Number} ms\n\
* @return {Context} self\n\
* @api private\n\
*/\n\
\n\
Context.prototype.slow = function(ms){\n\
this.runnable().slow(ms);\n\
return this;\n\
};\n\
\n\
/**\n\
* Inspect the context void of `._runnable`.\n\
*\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
Context.prototype.inspect = function(){\n\
return JSON.stringify(this, function(key, val){\n\
if ('_runnable' == key) return;\n\
if ('test' == key) return;\n\
return val;\n\
}, 2);\n\
};\n\
\n\
}); // module: context.js\n\
\n\
require.register(\"hook.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Runnable = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Hook`.\n\
*/\n\
\n\
module.exports = Hook;\n\
\n\
/**\n\
* Initialize a new `Hook` with the given `title` and callback `fn`.\n\
*\n\
* @param {String} title\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
function Hook(title, fn) {\n\
Runnable.call(this, title, fn);\n\
this.type = 'hook';\n\
}\n\
\n\
/**\n\
* Inherit from `Runnable.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Runnable.prototype;\n\
Hook.prototype = new F;\n\
Hook.prototype.constructor = Hook;\n\
\n\
\n\
/**\n\
* Get or set the test `err`.\n\
*\n\
* @param {Error} err\n\
* @return {Error}\n\
* @api public\n\
*/\n\
\n\
Hook.prototype.error = function(err){\n\
if (0 == arguments.length) {\n\
var err = this._error;\n\
this._error = null;\n\
return err;\n\
}\n\
\n\
this._error = err;\n\
};\n\
\n\
}); // module: hook.js\n\
\n\
require.register(\"interfaces/bdd.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Suite = require(\"undefined\")\n\
, Test = require(\"undefined\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* BDD-style interface:\n\
*\n\
* describe('Array', function(){\n\
* describe('#indexOf()', function(){\n\
* it('should return -1 when not present', function(){\n\
*\n\
* });\n\
*\n\
* it('should return the index when present', function(){\n\
*\n\
* });\n\
* });\n\
* });\n\
*\n\
*/\n\
\n\
module.exports = function(suite){\n\
var suites = [suite];\n\
\n\
suite.on('pre-require', function(context, file, mocha){\n\
\n\
/**\n\
* Execute before running tests.\n\
*/\n\
\n\
context.before = function(name, fn){\n\
suites[0].beforeAll(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after running tests.\n\
*/\n\
\n\
context.after = function(name, fn){\n\
suites[0].afterAll(name, fn);\n\
};\n\
\n\
/**\n\
* Execute before each test case.\n\
*/\n\
\n\
context.beforeEach = function(name, fn){\n\
suites[0].beforeEach(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after each test case.\n\
*/\n\
\n\
context.afterEach = function(name, fn){\n\
suites[0].afterEach(name, fn);\n\
};\n\
\n\
/**\n\
* Describe a \"suite\" with the given `title`\n\
* and callback `fn` containing nested suites\n\
* and/or tests.\n\
*/\n\
\n\
context.describe = context.context = function(title, fn){\n\
var suite = Suite.create(suites[0], title);\n\
suites.unshift(suite);\n\
fn.call(suite);\n\
suites.shift();\n\
return suite;\n\
};\n\
\n\
/**\n\
* Pending describe.\n\
*/\n\
\n\
context.xdescribe =\n\
context.xcontext =\n\
context.describe.skip = function(title, fn){\n\
var suite = Suite.create(suites[0], title);\n\
suite.pending = true;\n\
suites.unshift(suite);\n\
fn.call(suite);\n\
suites.shift();\n\
};\n\
\n\
/**\n\
* Exclusive suite.\n\
*/\n\
\n\
context.describe.only = function(title, fn){\n\
var suite = context.describe(title, fn);\n\
mocha.grep(suite.fullTitle());\n\
return suite;\n\
};\n\
\n\
/**\n\
* Describe a specification or test-case\n\
* with the given `title` and callback `fn`\n\
* acting as a thunk.\n\
*/\n\
\n\
context.it = context.specify = function(title, fn){\n\
var suite = suites[0];\n\
if (suite.pending) var fn = null;\n\
var test = new Test(title, fn);\n\
suite.addTest(test);\n\
return test;\n\
};\n\
\n\
/**\n\
* Exclusive test-case.\n\
*/\n\
\n\
context.it.only = function(title, fn){\n\
var test = context.it(title, fn);\n\
var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$';\n\
mocha.grep(new RegExp(reString));\n\
return test;\n\
};\n\
\n\
/**\n\
* Pending test case.\n\
*/\n\
\n\
context.xit =\n\
context.xspecify =\n\
context.it.skip = function(title){\n\
context.it(title);\n\
};\n\
});\n\
};\n\
\n\
}); // module: interfaces/bdd.js\n\
\n\
require.register(\"interfaces/exports.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Suite = require(\"undefined\")\n\
, Test = require(\"undefined\");\n\
\n\
/**\n\
* TDD-style interface:\n\
*\n\
* exports.Array = {\n\
* '#indexOf()': {\n\
* 'should return -1 when the value is not present': function(){\n\
*\n\
* },\n\
*\n\
* 'should return the correct index when the value is present': function(){\n\
*\n\
* }\n\
* }\n\
* };\n\
*\n\
*/\n\
\n\
module.exports = function(suite){\n\
var suites = [suite];\n\
\n\
suite.on('require', visit);\n\
\n\
function visit(obj) {\n\
var suite;\n\
for (var key in obj) {\n\
if ('function' == typeof obj[key]) {\n\
var fn = obj[key];\n\
switch (key) {\n\
case 'before':\n\
suites[0].beforeAll(fn);\n\
break;\n\
case 'after':\n\
suites[0].afterAll(fn);\n\
break;\n\
case 'beforeEach':\n\
suites[0].beforeEach(fn);\n\
break;\n\
case 'afterEach':\n\
suites[0].afterEach(fn);\n\
break;\n\
default:\n\
suites[0].addTest(new Test(key, fn));\n\
}\n\
} else {\n\
var suite = Suite.create(suites[0], key);\n\
suites.unshift(suite);\n\
visit(obj[key]);\n\
suites.shift();\n\
}\n\
}\n\
}\n\
};\n\
\n\
}); // module: interfaces/exports.js\n\
\n\
require.register(\"interfaces/index.js\", function(module, exports, require){\n\
\n\
exports.bdd = require(\"undefined\");\n\
exports.tdd = require(\"undefined\");\n\
exports.qunit = require(\"undefined\");\n\
exports.exports = require(\"undefined\");\n\
\n\
}); // module: interfaces/index.js\n\
\n\
require.register(\"interfaces/qunit.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Suite = require(\"undefined\")\n\
, Test = require(\"undefined\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* QUnit-style interface:\n\
*\n\
* suite('Array');\n\
*\n\
* test('#length', function(){\n\
* var arr = [1,2,3];\n\
* ok(arr.length == 3);\n\
* });\n\
*\n\
* test('#indexOf()', function(){\n\
* var arr = [1,2,3];\n\
* ok(arr.indexOf(1) == 0);\n\
* ok(arr.indexOf(2) == 1);\n\
* ok(arr.indexOf(3) == 2);\n\
* });\n\
*\n\
* suite('String');\n\
*\n\
* test('#length', function(){\n\
* ok('foo'.length == 3);\n\
* });\n\
*\n\
*/\n\
\n\
module.exports = function(suite){\n\
var suites = [suite];\n\
\n\
suite.on('pre-require', function(context, file, mocha){\n\
\n\
/**\n\
* Execute before running tests.\n\
*/\n\
\n\
context.before = function(name, fn){\n\
suites[0].beforeAll(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after running tests.\n\
*/\n\
\n\
context.after = function(name, fn){\n\
suites[0].afterAll(name, fn);\n\
};\n\
\n\
/**\n\
* Execute before each test case.\n\
*/\n\
\n\
context.beforeEach = function(name, fn){\n\
suites[0].beforeEach(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after each test case.\n\
*/\n\
\n\
context.afterEach = function(name, fn){\n\
suites[0].afterEach(name, fn);\n\
};\n\
\n\
/**\n\
* Describe a \"suite\" with the given `title`.\n\
*/\n\
\n\
context.suite = function(title){\n\
if (suites.length > 1) suites.shift();\n\
var suite = Suite.create(suites[0], title);\n\
suites.unshift(suite);\n\
return suite;\n\
};\n\
\n\
/**\n\
* Exclusive test-case.\n\
*/\n\
\n\
context.suite.only = function(title, fn){\n\
var suite = context.suite(title, fn);\n\
mocha.grep(suite.fullTitle());\n\
};\n\
\n\
/**\n\
* Describe a specification or test-case\n\
* with the given `title` and callback `fn`\n\
* acting as a thunk.\n\
*/\n\
\n\
context.test = function(title, fn){\n\
var test = new Test(title, fn);\n\
suites[0].addTest(test);\n\
return test;\n\
};\n\
\n\
/**\n\
* Exclusive test-case.\n\
*/\n\
\n\
context.test.only = function(title, fn){\n\
var test = context.test(title, fn);\n\
var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$';\n\
mocha.grep(new RegExp(reString));\n\
};\n\
\n\
/**\n\
* Pending test case.\n\
*/\n\
\n\
context.test.skip = function(title){\n\
context.test(title);\n\
};\n\
});\n\
};\n\
\n\
}); // module: interfaces/qunit.js\n\
\n\
require.register(\"interfaces/tdd.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Suite = require(\"undefined\")\n\
, Test = require(\"undefined\")\n\
, utils = require(\"undefined\");;\n\
\n\
/**\n\
* TDD-style interface:\n\
*\n\
* suite('Array', function(){\n\
* suite('#indexOf()', function(){\n\
* suiteSetup(function(){\n\
*\n\
* });\n\
*\n\
* test('should return -1 when not present', function(){\n\
*\n\
* });\n\
*\n\
* test('should return the index when present', function(){\n\
*\n\
* });\n\
*\n\
* suiteTeardown(function(){\n\
*\n\
* });\n\
* });\n\
* });\n\
*\n\
*/\n\
\n\
module.exports = function(suite){\n\
var suites = [suite];\n\
\n\
suite.on('pre-require', function(context, file, mocha){\n\
\n\
/**\n\
* Execute before each test case.\n\
*/\n\
\n\
context.setup = function(name, fn){\n\
suites[0].beforeEach(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after each test case.\n\
*/\n\
\n\
context.teardown = function(name, fn){\n\
suites[0].afterEach(name, fn);\n\
};\n\
\n\
/**\n\
* Execute before the suite.\n\
*/\n\
\n\
context.suiteSetup = function(name, fn){\n\
suites[0].beforeAll(name, fn);\n\
};\n\
\n\
/**\n\
* Execute after the suite.\n\
*/\n\
\n\
context.suiteTeardown = function(name, fn){\n\
suites[0].afterAll(name, fn);\n\
};\n\
\n\
/**\n\
* Describe a \"suite\" with the given `title`\n\
* and callback `fn` containing nested suites\n\
* and/or tests.\n\
*/\n\
\n\
context.suite = function(title, fn){\n\
var suite = Suite.create(suites[0], title);\n\
suites.unshift(suite);\n\
fn.call(suite);\n\
suites.shift();\n\
return suite;\n\
};\n\
\n\
/**\n\
* Pending suite.\n\
*/\n\
context.suite.skip = function(title, fn) {\n\
var suite = Suite.create(suites[0], title);\n\
suite.pending = true;\n\
suites.unshift(suite);\n\
fn.call(suite);\n\
suites.shift();\n\
};\n\
\n\
/**\n\
* Exclusive test-case.\n\
*/\n\
\n\
context.suite.only = function(title, fn){\n\
var suite = context.suite(title, fn);\n\
mocha.grep(suite.fullTitle());\n\
};\n\
\n\
/**\n\
* Describe a specification or test-case\n\
* with the given `title` and callback `fn`\n\
* acting as a thunk.\n\
*/\n\
\n\
context.test = function(title, fn){\n\
var suite = suites[0];\n\
if (suite.pending) var fn = null;\n\
var test = new Test(title, fn);\n\
suite.addTest(test);\n\
return test;\n\
};\n\
\n\
/**\n\
* Exclusive test-case.\n\
*/\n\
\n\
context.test.only = function(title, fn){\n\
var test = context.test(title, fn);\n\
var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$';\n\
mocha.grep(new RegExp(reString));\n\
};\n\
\n\
/**\n\
* Pending test case.\n\
*/\n\
\n\
context.test.skip = function(title){\n\
context.test(title);\n\
};\n\
});\n\
};\n\
\n\
}); // module: interfaces/tdd.js\n\
\n\
require.register(\"mocha.js\", function(module, exports, require){\n\
/*!\n\
* mocha\n\
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>\n\
* MIT Licensed\n\
*/\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var path = require(\"browser/path\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Mocha`.\n\
*/\n\
\n\
exports = module.exports = Mocha;\n\
\n\
/**\n\
* Expose internals.\n\
*/\n\
\n\
exports.utils = utils;\n\
exports.interfaces = require(\"undefined\");\n\
exports.reporters = require(\"undefined\");\n\
exports.Runnable = require(\"undefined\");\n\
exports.Context = require(\"undefined\");\n\
exports.Runner = require(\"undefined\");\n\
exports.Suite = require(\"undefined\");\n\
exports.Hook = require(\"undefined\");\n\
exports.Test = require(\"undefined\");\n\
\n\
/**\n\
* Return image `name` path.\n\
*\n\
* @param {String} name\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function image(name) {\n\
return __dirname + '/../images/' + name + '.png';\n\
}\n\
\n\
/**\n\
* Setup mocha with `options`.\n\
*\n\
* Options:\n\
*\n\
* - `ui` name \"bdd\", \"tdd\", \"exports\" etc\n\
* - `reporter` reporter instance, defaults to `mocha.reporters.Dot`\n\
* - `globals` array of accepted globals\n\
* - `timeout` timeout in milliseconds\n\
* - `bail` bail on the first test failure\n\
* - `slow` milliseconds to wait before considering a test slow\n\
* - `ignoreLeaks` ignore global leaks\n\
* - `grep` string or regexp to filter tests with\n\
*\n\
* @param {Object} options\n\
* @api public\n\
*/\n\
\n\
function Mocha(options) {\n\
options = options || {};\n\
this.files = [];\n\
this.options = options;\n\
this.grep(options.grep);\n\
this.suite = new exports.Suite('', new exports.Context);\n\
this.ui(options.ui);\n\
this.bail(options.bail);\n\
this.reporter(options.reporter);\n\
if (null != options.timeout) this.timeout(options.timeout);\n\
this.useColors(options.useColors)\n\
if (options.slow) this.slow(options.slow);\n\
\n\
this.suite.on('pre-require', function (context) {\n\
exports.afterEach = context.afterEach || context.teardown;\n\
exports.after = context.after || context.suiteTeardown;\n\
exports.beforeEach = context.beforeEach || context.setup;\n\
exports.before = context.before || context.suiteSetup;\n\
exports.describe = context.describe || context.suite;\n\
exports.it = context.it || context.test;\n\
exports.setup = context.setup || context.beforeEach;\n\
exports.suiteSetup = context.suiteSetup || context.before;\n\
exports.suiteTeardown = context.suiteTeardown || context.after;\n\
exports.suite = context.suite || context.describe;\n\
exports.teardown = context.teardown || context.afterEach;\n\
exports.test = context.test || context.it;\n\
});\n\
}\n\
\n\
/**\n\
* Enable or disable bailing on the first failure.\n\
*\n\
* @param {Boolean} [bail]\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.bail = function(bail){\n\
if (0 == arguments.length) bail = true;\n\
this.suite.bail(bail);\n\
return this;\n\
};\n\
\n\
/**\n\
* Add test `file`.\n\
*\n\
* @param {String} file\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.addFile = function(file){\n\
this.files.push(file);\n\
return this;\n\
};\n\
\n\
/**\n\
* Set reporter to `reporter`, defaults to \"dot\".\n\
*\n\
* @param {String|Function} reporter name or constructor\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.reporter = function(reporter){\n\
if ('function' == typeof reporter) {\n\
this._reporter = reporter;\n\
} else {\n\
reporter = reporter || 'dot';\n\
var _reporter;\n\
try { _reporter = require('./reporters/' + reporter); } catch (err) {};\n\
if (!_reporter) try { _reporter = require(reporter); } catch (err) {};\n\
if (!_reporter && reporter === 'teamcity')\n\
console.warn('The Teamcity reporter was moved to a package named ' +\n\
'mocha-teamcity-reporter ' +\n\
'(https://npmjs.org/package/mocha-teamcity-reporter).');\n\
if (!_reporter) throw new Error('invalid reporter \"' + reporter + '\"');\n\
this._reporter = _reporter;\n\
}\n\
return this;\n\
};\n\
\n\
/**\n\
* Set test UI `name`, defaults to \"bdd\".\n\
*\n\
* @param {String} bdd\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.ui = function(name){\n\
name = name || 'bdd';\n\
this._ui = exports.interfaces[name];\n\
if (!this._ui) try { this._ui = require(name); } catch (err) {};\n\
if (!this._ui) throw new Error('invalid interface \"' + name + '\"');\n\
this._ui = this._ui(this.suite);\n\
return this;\n\
};\n\
\n\
/**\n\
* Load registered files.\n\
*\n\
* @api private\n\
*/\n\
\n\
Mocha.prototype.loadFiles = function(fn){\n\
var self = this;\n\
var suite = this.suite;\n\
var pending = this.files.length;\n\
this.files.forEach(function(file){\n\
file = path.resolve(file);\n\
suite.emit('pre-require', global, file, self);\n\
suite.emit('require', require(file), file, self);\n\
suite.emit('post-require', global, file, self);\n\
--pending || (fn && fn());\n\
});\n\
};\n\
\n\
/**\n\
* Enable growl support.\n\
*\n\
* @api private\n\
*/\n\
\n\
Mocha.prototype._growl = function(runner, reporter) {\n\
var notify = require(\"growl\");\n\
\n\
runner.on('end', function(){\n\
var stats = reporter.stats;\n\
if (stats.failures) {\n\
var msg = stats.failures + ' of ' + runner.total + ' tests failed';\n\
notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });\n\
} else {\n\
notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {\n\
name: 'mocha'\n\
, title: 'Passed'\n\
, image: image('ok')\n\
});\n\
}\n\
});\n\
};\n\
\n\
/**\n\
* Add regexp to grep, if `re` is a string it is escaped.\n\
*\n\
* @param {RegExp|String} re\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.grep = function(re){\n\
this.options.grep = 'string' == typeof re\n\
? new RegExp(utils.escapeRegexp(re))\n\
: re;\n\
return this;\n\
};\n\
\n\
/**\n\
* Invert `.grep()` matches.\n\
*\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.invert = function(){\n\
this.options.invert = true;\n\
return this;\n\
};\n\
\n\
/**\n\
* Ignore global leaks.\n\
*\n\
* @param {Boolean} ignore\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.ignoreLeaks = function(ignore){\n\
this.options.ignoreLeaks = !!ignore;\n\
return this;\n\
};\n\
\n\
/**\n\
* Enable global leak checking.\n\
*\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.checkLeaks = function(){\n\
this.options.ignoreLeaks = false;\n\
return this;\n\
};\n\
\n\
/**\n\
* Enable growl support.\n\
*\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.growl = function(){\n\
this.options.growl = true;\n\
return this;\n\
};\n\
\n\
/**\n\
* Ignore `globals` array or string.\n\
*\n\
* @param {Array|String} globals\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.globals = function(globals){\n\
this.options.globals = (this.options.globals || []).concat(globals);\n\
return this;\n\
};\n\
\n\
/**\n\
* Emit color output.\n\
*\n\
* @param {Boolean} colors\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.useColors = function(colors){\n\
this.options.useColors = arguments.length && colors != undefined\n\
? colors\n\
: true;\n\
return this;\n\
};\n\
\n\
/**\n\
* Use inline diffs rather than +/-.\n\
*\n\
* @param {Boolean} inlineDiffs\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {\n\
this.options.useInlineDiffs = arguments.length && inlineDiffs != undefined\n\
? inlineDiffs\n\
: false;\n\
return this;\n\
};\n\
\n\
/**\n\
* Set the timeout in milliseconds.\n\
*\n\
* @param {Number} timeout\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.timeout = function(timeout){\n\
this.suite.timeout(timeout);\n\
return this;\n\
};\n\
\n\
/**\n\
* Set slowness threshold in milliseconds.\n\
*\n\
* @param {Number} slow\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.slow = function(slow){\n\
this.suite.slow(slow);\n\
return this;\n\
};\n\
\n\
/**\n\
* Makes all tests async (accepting a callback)\n\
*\n\
* @return {Mocha}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.asyncOnly = function(){\n\
this.options.asyncOnly = true;\n\
return this;\n\
};\n\
\n\
/**\n\
* Run tests and invoke `fn()` when complete.\n\
*\n\
* @param {Function} fn\n\
* @return {Runner}\n\
* @api public\n\
*/\n\
\n\
Mocha.prototype.run = function(fn){\n\
if (this.files.length) this.loadFiles();\n\
var suite = this.suite;\n\
var options = this.options;\n\
options.files = this.files;\n\
var runner = new exports.Runner(suite);\n\
var reporter = new this._reporter(runner, options);\n\
runner.ignoreLeaks = false !== options.ignoreLeaks;\n\
runner.asyncOnly = options.asyncOnly;\n\
if (options.grep) runner.grep(options.grep, options.invert);\n\
if (options.globals) runner.globals(options.globals);\n\
if (options.growl) this._growl(runner, reporter);\n\
exports.reporters.Base.useColors = options.useColors;\n\
exports.reporters.Base.inlineDiffs = options.useInlineDiffs;\n\
return runner.run(fn);\n\
};\n\
\n\
}); // module: mocha.js\n\
\n\
require.register(\"ms.js\", function(module, exports, require){\n\
/**\n\
* Helpers.\n\
*/\n\
\n\
var s = 1000;\n\
var m = s * 60;\n\
var h = m * 60;\n\
var d = h * 24;\n\
var y = d * 365.25;\n\
\n\
/**\n\
* Parse or format the given `val`.\n\
*\n\
* Options:\n\
*\n\
* - `long` verbose formatting [false]\n\
*\n\
* @param {String|Number} val\n\
* @param {Object} options\n\
* @return {String|Number}\n\
* @api public\n\
*/\n\
\n\
module.exports = function(val, options){\n\
options = options || {};\n\
if ('string' == typeof val) return parse(val);\n\
return options.long ? longFormat(val) : shortFormat(val);\n\
};\n\
\n\
/**\n\
* Parse the given `str` and return milliseconds.\n\
*\n\
* @param {String} str\n\
* @return {Number}\n\
* @api private\n\
*/\n\
\n\
function parse(str) {\n\
var match = /^((?:\\d+)?\\.?\\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);\n\
if (!match) return;\n\
var n = parseFloat(match[1]);\n\
var type = (match[2] || 'ms').toLowerCase();\n\
switch (type) {\n\
case 'years':\n\
case 'year':\n\
case 'y':\n\
return n * y;\n\
case 'days':\n\
case 'day':\n\
case 'd':\n\
return n * d;\n\
case 'hours':\n\
case 'hour':\n\
case 'h':\n\
return n * h;\n\
case 'minutes':\n\
case 'minute':\n\
case 'm':\n\
return n * m;\n\
case 'seconds':\n\
case 'second':\n\
case 's':\n\
return n * s;\n\
case 'ms':\n\
return n;\n\
}\n\
}\n\
\n\
/**\n\
* Short format for `ms`.\n\
*\n\
* @param {Number} ms\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function shortFormat(ms) {\n\
if (ms >= d) return Math.round(ms / d) + 'd';\n\
if (ms >= h) return Math.round(ms / h) + 'h';\n\
if (ms >= m) return Math.round(ms / m) + 'm';\n\
if (ms >= s) return Math.round(ms / s) + 's';\n\
return ms + 'ms';\n\
}\n\
\n\
/**\n\
* Long format for `ms`.\n\
*\n\
* @param {Number} ms\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function longFormat(ms) {\n\
return plural(ms, d, 'day')\n\
|| plural(ms, h, 'hour')\n\
|| plural(ms, m, 'minute')\n\
|| plural(ms, s, 'second')\n\
|| ms + ' ms';\n\
}\n\
\n\
/**\n\
* Pluralization helper.\n\
*/\n\
\n\
function plural(ms, n, name) {\n\
if (ms < n) return;\n\
if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n\
return Math.ceil(ms / n) + ' ' + name + 's';\n\
}\n\
\n\
}); // module: ms.js\n\
\n\
require.register(\"reporters/base.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var tty = require(\"browser/tty\")\n\
, diff = require(\"browser/diff\")\n\
, ms = require(\"undefined\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* Save timer references to avoid Sinon interfering (see GH-237).\n\
*/\n\
\n\
var Date = global.Date\n\
, setTimeout = global.setTimeout\n\
, setInterval = global.setInterval\n\
, clearTimeout = global.clearTimeout\n\
, clearInterval = global.clearInterval;\n\
\n\
/**\n\
* Check if both stdio streams are associated with a tty.\n\
*/\n\
\n\
var isatty = tty.isatty(1) && tty.isatty(2);\n\
\n\
/**\n\
* Expose `Base`.\n\
*/\n\
\n\
exports = module.exports = Base;\n\
\n\
/**\n\
* Enable coloring by default.\n\
*/\n\
\n\
exports.useColors = isatty || (process.env.MOCHA_COLORS !== undefined);\n\
\n\
/**\n\
* Inline diffs instead of +/-\n\
*/\n\
\n\
exports.inlineDiffs = false;\n\
\n\
/**\n\
* Default color map.\n\
*/\n\
\n\
exports.colors = {\n\
'pass': 90\n\
, 'fail': 31\n\
, 'bright pass': 92\n\
, 'bright fail': 91\n\
, 'bright yellow': 93\n\
, 'pending': 36\n\
, 'suite': 0\n\
, 'error title': 0\n\
, 'error message': 31\n\
, 'error stack': 90\n\
, 'checkmark': 32\n\
, 'fast': 90\n\
, 'medium': 33\n\
, 'slow': 31\n\
, 'green': 32\n\
, 'light': 90\n\
, 'diff gutter': 90\n\
, 'diff added': 42\n\
, 'diff removed': 41\n\
};\n\
\n\
/**\n\
* Default symbol map.\n\
*/\n\
\n\
exports.symbols = {\n\
ok: '✓',\n\
err: '✖',\n\
dot: '․'\n\
};\n\
\n\
// With node.js on Windows: use symbols available in terminal default fonts\n\
if ('win32' == process.platform) {\n\
exports.symbols.ok = '\\u221A';\n\
exports.symbols.err = '\\u00D7';\n\
exports.symbols.dot = '.';\n\
}\n\
\n\
/**\n\
* Color `str` with the given `type`,\n\
* allowing colors to be disabled,\n\
* as well as user-defined color\n\
* schemes.\n\
*\n\
* @param {String} type\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
var color = exports.color = function(type, str) {\n\
if (!exports.useColors) return str;\n\
return '\\u001b[' + exports.colors[type] + 'm' + str + '\\u001b[0m';\n\
};\n\
\n\
/**\n\
* Expose term window size, with some\n\
* defaults for when stderr is not a tty.\n\
*/\n\
\n\
exports.window = {\n\
width: isatty\n\
? process.stdout.getWindowSize\n\
? process.stdout.getWindowSize(1)[0]\n\
: tty.getWindowSize()[1]\n\
: 75\n\
};\n\
\n\
/**\n\
* Expose some basic cursor interactions\n\
* that are common among reporters.\n\
*/\n\
\n\
exports.cursor = {\n\
hide: function(){\n\
isatty && process.stdout.write('\\u001b[?25l');\n\
},\n\
\n\
show: function(){\n\
isatty && process.stdout.write('\\u001b[?25h');\n\
},\n\
\n\
deleteLine: function(){\n\
isatty && process.stdout.write('\\u001b[2K');\n\
},\n\
\n\
beginningOfLine: function(){\n\
isatty && process.stdout.write('\\u001b[0G');\n\
},\n\
\n\
CR: function(){\n\
if (isatty) {\n\
exports.cursor.deleteLine();\n\
exports.cursor.beginningOfLine();\n\
} else {\n\
process.stdout.write('\\r');\n\
}\n\
}\n\
};\n\
\n\
/**\n\
* Outut the given `failures` as a list.\n\
*\n\
* @param {Array} failures\n\
* @api public\n\
*/\n\
\n\
exports.list = function(failures){\n\
console.error();\n\
failures.forEach(function(test, i){\n\
// format\n\
var fmt = color('error title', ' %s) %s:\\n\
')\n\
+ color('error message', ' %s')\n\
+ color('error stack', '\\n\
%s\\n\
');\n\
\n\
// msg\n\
var err = test.err\n\
, message = err.message || ''\n\
, stack = err.stack || message\n\
, index = stack.indexOf(message) + message.length\n\
, msg = stack.slice(0, index)\n\
, actual = err.actual\n\
, expected = err.expected\n\
, escape = true;\n\
\n\
// uncaught\n\
if (err.uncaught) {\n\
msg = 'Uncaught ' + msg;\n\
}\n\
\n\
// explicitly show diff\n\
if (err.showDiff && sameType(actual, expected)) {\n\
escape = false;\n\
err.actual = actual = stringify(canonicalize(actual));\n\
err.expected = expected = stringify(canonicalize(expected));\n\
}\n\
\n\
// actual / expected diff\n\
if ('string' == typeof actual && 'string' == typeof expected) {\n\
fmt = color('error title', ' %s) %s:\\n\
%s') + color('error stack', '\\n\
%s\\n\
');\n\
var match = message.match(/^([^:]+): expected/);\n\
msg = '\\n\
' + color('error message', match ? match[1] : msg);\n\
\n\
if (exports.inlineDiffs) {\n\
msg += inlineDiff(err, escape);\n\
} else {\n\
msg += unifiedDiff(err, escape);\n\
}\n\
}\n\
\n\
// indent stack trace without msg\n\
stack = stack.slice(index ? index + 1 : index)\n\
.replace(/^/gm, ' ');\n\
\n\
console.error(fmt, (i + 1), test.fullTitle(), msg, stack);\n\
});\n\
};\n\
\n\
/**\n\
* Initialize a new `Base` reporter.\n\
*\n\
* All other reporters generally\n\
* inherit from this reporter, providing\n\
* stats such as test duration, number\n\
* of tests passed / failed etc.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Base(runner) {\n\
var self = this\n\
, stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }\n\
, failures = this.failures = [];\n\
\n\
if (!runner) return;\n\
this.runner = runner;\n\
\n\
runner.stats = stats;\n\
\n\
runner.on('start', function(){\n\
stats.start = new Date;\n\
});\n\
\n\
runner.on('suite', function(suite){\n\
stats.suites = stats.suites || 0;\n\
suite.root || stats.suites++;\n\
});\n\
\n\
runner.on('test end', function(test){\n\
stats.tests = stats.tests || 0;\n\
stats.tests++;\n\
});\n\
\n\
runner.on('pass', function(test){\n\
stats.passes = stats.passes || 0;\n\
\n\
var medium = test.slow() / 2;\n\
test.speed = test.duration > test.slow()\n\
? 'slow'\n\
: test.duration > medium\n\
? 'medium'\n\
: 'fast';\n\
\n\
stats.passes++;\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
stats.failures = stats.failures || 0;\n\
stats.failures++;\n\
test.err = err;\n\
failures.push(test);\n\
});\n\
\n\
runner.on('end', function(){\n\
stats.end = new Date;\n\
stats.duration = new Date - stats.start;\n\
});\n\
\n\
runner.on('pending', function(){\n\
stats.pending++;\n\
});\n\
}\n\
\n\
/**\n\
* Output common epilogue used by many of\n\
* the bundled reporters.\n\
*\n\
* @api public\n\
*/\n\
\n\
Base.prototype.epilogue = function(){\n\
var stats = this.stats;\n\
var tests;\n\
var fmt;\n\
\n\
console.log();\n\
\n\
// passes\n\
fmt = color('bright pass', ' ')\n\
+ color('green', ' %d passing')\n\
+ color('light', ' (%s)');\n\
\n\
console.log(fmt,\n\
stats.passes || 0,\n\
ms(stats.duration));\n\
\n\
// pending\n\
if (stats.pending) {\n\
fmt = color('pending', ' ')\n\
+ color('pending', ' %d pending');\n\
\n\
console.log(fmt, stats.pending);\n\
}\n\
\n\
// failures\n\
if (stats.failures) {\n\
fmt = color('fail', ' %d failing');\n\
\n\
console.error(fmt,\n\
stats.failures);\n\
\n\
Base.list(this.failures);\n\
console.error();\n\
}\n\
\n\
console.log();\n\
};\n\
\n\
/**\n\
* Pad the given `str` to `len`.\n\
*\n\
* @param {String} str\n\
* @param {String} len\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function pad(str, len) {\n\
str = String(str);\n\
return Array(len - str.length + 1).join(' ') + str;\n\
}\n\
\n\
\n\
/**\n\
* Returns an inline diff between 2 strings with coloured ANSI output\n\
*\n\
* @param {Error} Error with actual/expected\n\
* @return {String} Diff\n\
* @api private\n\
*/\n\
\n\
function inlineDiff(err, escape) {\n\
var msg = errorDiff(err, 'WordsWithSpace', escape);\n\
\n\
// linenos\n\
var lines = msg.split('\\n\
');\n\
if (lines.length > 4) {\n\
var width = String(lines.length).length;\n\
msg = lines.map(function(str, i){\n\
return pad(++i, width) + ' |' + ' ' + str;\n\
}).join('\\n\
');\n\
}\n\
\n\
// legend\n\
msg = '\\n\
'\n\
+ color('diff removed', 'actual')\n\
+ ' '\n\
+ color('diff added', 'expected')\n\
+ '\\n\
\\n\
'\n\
+ msg\n\
+ '\\n\
';\n\
\n\
// indent\n\
msg = msg.replace(/^/gm, ' ');\n\
return msg;\n\
}\n\
\n\
/**\n\
* Returns a unified diff between 2 strings\n\
*\n\
* @param {Error} Error with actual/expected\n\
* @return {String} Diff\n\
* @api private\n\
*/\n\
\n\
function unifiedDiff(err, escape) {\n\
var indent = ' ';\n\
function cleanUp(line) {\n\
if (escape) {\n\
line = escapeInvisibles(line);\n\
}\n\
if (line[0] === '+') return indent + colorLines('diff added', line);\n\
if (line[0] === '-') return indent + colorLines('diff removed', line);\n\
if (line.match(/\\@\\@/)) return null;\n\
if (line.match(/\\\\ No newline/)) return null;\n\
else return indent + line;\n\
}\n\
function notBlank(line) {\n\
return line != null;\n\
}\n\
msg = diff.createPatch('string', err.actual, err.expected);\n\
var lines = msg.split('\\n\
').splice(4);\n\
return '\\n\
'\n\
+ colorLines('diff added', '+ expected') + ' '\n\
+ colorLines('diff removed', '- actual')\n\
+ '\\n\
\\n\
'\n\
+ lines.map(cleanUp).filter(notBlank).join('\\n\
');\n\
}\n\
\n\
/**\n\
* Return a character diff for `err`.\n\
*\n\
* @param {Error} err\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function errorDiff(err, type, escape) {\n\
var actual = escape ? escapeInvisibles(err.actual) : err.actual;\n\
var expected = escape ? escapeInvisibles(err.expected) : err.expected;\n\
return diff['diff' + type](actual, expected).map(function(str){\n\
if (str.added) return colorLines('diff added', str.value);\n\
if (str.removed) return colorLines('diff removed', str.value);\n\
return str.value;\n\
}).join('');\n\
}\n\
\n\
/**\n\
* Returns a string with all invisible characters in plain text\n\
*\n\
* @param {String} line\n\
* @return {String}\n\
* @api private\n\
*/\n\
function escapeInvisibles(line) {\n\
return line.replace(/\\t/g, '<tab>')\n\
.replace(/\\r/g, '<CR>')\n\
.replace(/\\n\
/g, '<LF>\\n\
');\n\
}\n\
\n\
/**\n\
* Color lines for `str`, using the color `name`.\n\
*\n\
* @param {String} name\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function colorLines(name, str) {\n\
return str.split('\\n\
').map(function(str){\n\
return color(name, str);\n\
}).join('\\n\
');\n\
}\n\
\n\
/**\n\
* Stringify `obj`.\n\
*\n\
* @param {Object} obj\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function stringify(obj) {\n\
if (obj instanceof RegExp) return obj.toString();\n\
return JSON.stringify(obj, null, 2);\n\
}\n\
\n\
/**\n\
* Return a new object that has the keys in sorted order.\n\
* @param {Object} obj\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function canonicalize(obj, stack) {\n\
stack = stack || [];\n\
\n\
if (utils.indexOf(stack, obj) !== -1) return obj;\n\
\n\
var canonicalizedObj;\n\
\n\
if ('[object Array]' == {}.toString.call(obj)) {\n\
stack.push(obj);\n\
canonicalizedObj = utils.map(obj, function(item) {\n\
return canonicalize(item, stack);\n\
});\n\
stack.pop();\n\
} else if (typeof obj === 'object' && obj !== null) {\n\
stack.push(obj);\n\
canonicalizedObj = {};\n\
utils.forEach(utils.keys(obj).sort(), function(key) {\n\
canonicalizedObj[key] = canonicalize(obj[key], stack);\n\
});\n\
stack.pop();\n\
} else {\n\
canonicalizedObj = obj;\n\
}\n\
\n\
return canonicalizedObj;\n\
}\n\
\n\
/**\n\
* Check that a / b have the same type.\n\
*\n\
* @param {Object} a\n\
* @param {Object} b\n\
* @return {Boolean}\n\
* @api private\n\
*/\n\
\n\
function sameType(a, b) {\n\
a = Object.prototype.toString.call(a);\n\
b = Object.prototype.toString.call(b);\n\
return a == b;\n\
}\n\
\n\
\n\
}); // module: reporters/base.js\n\
\n\
require.register(\"reporters/doc.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Doc`.\n\
*/\n\
\n\
exports = module.exports = Doc;\n\
\n\
/**\n\
* Initialize a new `Doc` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Doc(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, total = runner.total\n\
, indents = 2;\n\
\n\
function indent() {\n\
return Array(indents).join(' ');\n\
}\n\
\n\
runner.on('suite', function(suite){\n\
if (suite.root) return;\n\
++indents;\n\
console.log('%s<section class=\"suite\">', indent());\n\
++indents;\n\
console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));\n\
console.log('%s<dl>', indent());\n\
});\n\
\n\
runner.on('suite end', function(suite){\n\
if (suite.root) return;\n\
console.log('%s</dl>', indent());\n\
--indents;\n\
console.log('%s</section>', indent());\n\
--indents;\n\
});\n\
\n\
runner.on('pass', function(test){\n\
console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));\n\
var code = utils.escape(utils.clean(test.fn.toString()));\n\
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);\n\
});\n\
}\n\
\n\
}); // module: reporters/doc.js\n\
\n\
require.register(\"reporters/dot.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `Dot`.\n\
*/\n\
\n\
exports = module.exports = Dot;\n\
\n\
/**\n\
* Initialize a new `Dot` matrix test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Dot(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, width = Base.window.width * .75 | 0\n\
, n = 0;\n\
\n\
runner.on('start', function(){\n\
process.stdout.write('\\n\
');\n\
});\n\
\n\
runner.on('pending', function(test){\n\
process.stdout.write(color('pending', Base.symbols.dot));\n\
});\n\
\n\
runner.on('pass', function(test){\n\
if (++n % width == 0) process.stdout.write('\\n\
');\n\
if ('slow' == test.speed) {\n\
process.stdout.write(color('bright yellow', Base.symbols.dot));\n\
} else {\n\
process.stdout.write(color(test.speed, Base.symbols.dot));\n\
}\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
if (++n % width == 0) process.stdout.write('\\n\
');\n\
process.stdout.write(color('fail', Base.symbols.dot));\n\
});\n\
\n\
runner.on('end', function(){\n\
console.log();\n\
self.epilogue();\n\
});\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
Dot.prototype = new F;\n\
Dot.prototype.constructor = Dot;\n\
\n\
}); // module: reporters/dot.js\n\
\n\
require.register(\"reporters/html-cov.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var JSONCov = require(\"undefined\")\n\
, fs = require(\"browser/fs\");\n\
\n\
/**\n\
* Expose `HTMLCov`.\n\
*/\n\
\n\
exports = module.exports = HTMLCov;\n\
\n\
/**\n\
* Initialize a new `JsCoverage` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function HTMLCov(runner) {\n\
var jade = require(\"jade\")\n\
, file = __dirname + '/templates/coverage.jade'\n\
, str = fs.readFileSync(file, 'utf8')\n\
, fn = jade.compile(str, { filename: file })\n\
, self = this;\n\
\n\
JSONCov.call(this, runner, false);\n\
\n\
runner.on('end', function(){\n\
process.stdout.write(fn({\n\
cov: self.cov\n\
, coverageClass: coverageClass\n\
}));\n\
});\n\
}\n\
\n\
/**\n\
* Return coverage class for `n`.\n\
*\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function coverageClass(n) {\n\
if (n >= 75) return 'high';\n\
if (n >= 50) return 'medium';\n\
if (n >= 25) return 'low';\n\
return 'terrible';\n\
}\n\
}); // module: reporters/html-cov.js\n\
\n\
require.register(\"reporters/html.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, utils = require(\"undefined\")\n\
, Progress = require(\"undefined\")\n\
, escape = utils.escape;\n\
\n\
/**\n\
* Save timer references to avoid Sinon interfering (see GH-237).\n\
*/\n\
\n\
var Date = global.Date\n\
, setTimeout = global.setTimeout\n\
, setInterval = global.setInterval\n\
, clearTimeout = global.clearTimeout\n\
, clearInterval = global.clearInterval;\n\
\n\
/**\n\
* Expose `HTML`.\n\
*/\n\
\n\
exports = module.exports = HTML;\n\
\n\
/**\n\
* Stats template.\n\
*/\n\
\n\
var statsTemplate = '<ul id=\"mocha-stats\">'\n\
+ '<li class=\"progress\"><canvas width=\"40\" height=\"40\"></canvas></li>'\n\
+ '<li class=\"passes\"><a href=\"#\">passes:</a> <em>0</em></li>'\n\
+ '<li class=\"failures\"><a href=\"#\">failures:</a> <em>0</em></li>'\n\
+ '<li class=\"duration\">duration: <em>0</em>s</li>'\n\
+ '</ul>';\n\
\n\
/**\n\
* Initialize a new `HTML` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function HTML(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, total = runner.total\n\
, stat = fragment(statsTemplate)\n\
, items = stat.getElementsByTagName('li')\n\
, passes = items[1].getElementsByTagName('em')[0]\n\
, passesLink = items[1].getElementsByTagName('a')[0]\n\
, failures = items[2].getElementsByTagName('em')[0]\n\
, failuresLink = items[2].getElementsByTagName('a')[0]\n\
, duration = items[3].getElementsByTagName('em')[0]\n\
, canvas = stat.getElementsByTagName('canvas')[0]\n\
, report = fragment('<ul id=\"mocha-report\"></ul>')\n\
, stack = [report]\n\
, progress\n\
, ctx\n\
, root = document.getElementById('mocha');\n\
\n\
if (canvas.getContext) {\n\
var ratio = window.devicePixelRatio || 1;\n\
canvas.style.width = canvas.width;\n\
canvas.style.height = canvas.height;\n\
canvas.width *= ratio;\n\
canvas.height *= ratio;\n\
ctx = canvas.getContext('2d');\n\
ctx.scale(ratio, ratio);\n\
progress = new Progress;\n\
}\n\
\n\
if (!root) return error('#mocha div missing, add it to your document');\n\
\n\
// pass toggle\n\
on(passesLink, 'click', function(){\n\
unhide();\n\
var name = /pass/.test(report.className) ? '' : ' pass';\n\
report.className = report.className.replace(/fail|pass/g, '') + name;\n\
if (report.className.trim()) hideSuitesWithout('test pass');\n\
});\n\
\n\
// failure toggle\n\
on(failuresLink, 'click', function(){\n\
unhide();\n\
var name = /fail/.test(report.className) ? '' : ' fail';\n\
report.className = report.className.replace(/fail|pass/g, '') + name;\n\
if (report.className.trim()) hideSuitesWithout('test fail');\n\
});\n\
\n\
root.appendChild(stat);\n\
root.appendChild(report);\n\
\n\
if (progress) progress.size(40);\n\
\n\
runner.on('suite', function(suite){\n\
if (suite.root) return;\n\
\n\
// suite\n\
var url = self.suiteURL(suite);\n\
var el = fragment('<li class=\"suite\"><h1><a href=\"%s\">%s</a></h1></li>', url, escape(suite.title));\n\
\n\
// container\n\
stack[0].appendChild(el);\n\
stack.unshift(document.createElement('ul'));\n\
el.appendChild(stack[0]);\n\
});\n\
\n\
runner.on('suite end', function(suite){\n\
if (suite.root) return;\n\
stack.shift();\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
if ('hook' == test.type) runner.emit('test end', test);\n\
});\n\
\n\
runner.on('test end', function(test){\n\
// TODO: add to stats\n\
var percent = stats.tests / this.total * 100 | 0;\n\
if (progress) progress.update(percent).draw(ctx);\n\
\n\
// update stats\n\
var ms = new Date - stats.start;\n\
text(passes, stats.passes);\n\
text(failures, stats.failures);\n\
text(duration, (ms / 1000).toFixed(2));\n\
\n\
// test\n\
if ('passed' == test.state) {\n\
var url = self.testURL(test);\n\
var el = fragment('<li class=\"test pass %e\"><h2>%e<span class=\"duration\">%ems</span> <a href=\"%s\" class=\"replay\">‣</a></h2></li>', test.speed, test.title, test.duration, url);\n\
} else if (test.pending) {\n\
var el = fragment('<li class=\"test pass pending\"><h2>%e</h2></li>', test.title);\n\
} else {\n\
var el = fragment('<li class=\"test fail\"><h2>%e <a href=\"?grep=%e\" class=\"replay\">‣</a></h2></li>', test.title, encodeURIComponent(test.fullTitle()));\n\
var str = test.err.stack || test.err.toString();\n\
\n\
// FF / Opera do not add the message\n\
if (!~str.indexOf(test.err.message)) {\n\
str = test.err.message + '\\n\
' + str;\n\
}\n\
\n\
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we\n\
// check for the result of the stringifying.\n\
if ('[object Error]' == str) str = test.err.message;\n\
\n\
// Safari doesn't give you a stack. Let's at least provide a source line.\n\
if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) {\n\
str += \"\\n\
(\" + test.err.sourceURL + \":\" + test.err.line + \")\";\n\
}\n\
\n\
el.appendChild(fragment('<pre class=\"error\">%e</pre>', str));\n\
}\n\
\n\
// toggle code\n\
// TODO: defer\n\
if (!test.pending) {\n\
var h2 = el.getElementsByTagName('h2')[0];\n\
\n\
on(h2, 'click', function(){\n\
pre.style.display = 'none' == pre.style.display\n\
? 'block'\n\
: 'none';\n\
});\n\
\n\
var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));\n\
el.appendChild(pre);\n\
pre.style.display = 'none';\n\
}\n\
\n\
// Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.\n\
if (stack[0]) stack[0].appendChild(el);\n\
});\n\
}\n\
\n\
/**\n\
* Provide suite URL\n\
*\n\
* @param {Object} [suite]\n\
*/\n\
\n\
HTML.prototype.suiteURL = function(suite){\n\
return '?grep=' + encodeURIComponent(suite.fullTitle());\n\
};\n\
\n\
/**\n\
* Provide test URL\n\
*\n\
* @param {Object} [test]\n\
*/\n\
\n\
HTML.prototype.testURL = function(test){\n\
return '?grep=' + encodeURIComponent(test.fullTitle());\n\
};\n\
\n\
/**\n\
* Display error `msg`.\n\
*/\n\
\n\
function error(msg) {\n\
document.body.appendChild(fragment('<div id=\"mocha-error\">%s</div>', msg));\n\
}\n\
\n\
/**\n\
* Return a DOM fragment from `html`.\n\
*/\n\
\n\
function fragment(html) {\n\
var args = arguments\n\
, div = document.createElement('div')\n\
, i = 1;\n\
\n\
div.innerHTML = html.replace(/%([se])/g, function(_, type){\n\
switch (type) {\n\
case 's': return String(args[i++]);\n\
case 'e': return escape(args[i++]);\n\
}\n\
});\n\
\n\
return div.firstChild;\n\
}\n\
\n\
/**\n\
* Check for suites that do not have elements\n\
* with `classname`, and hide them.\n\
*/\n\
\n\
function hideSuitesWithout(classname) {\n\
var suites = document.getElementsByClassName('suite');\n\
for (var i = 0; i < suites.length; i++) {\n\
var els = suites[i].getElementsByClassName(classname);\n\
if (0 == els.length) suites[i].className += ' hidden';\n\
}\n\
}\n\
\n\
/**\n\
* Unhide .hidden suites.\n\
*/\n\
\n\
function unhide() {\n\
var els = document.getElementsByClassName('suite hidden');\n\
for (var i = 0; i < els.length; ++i) {\n\
els[i].className = els[i].className.replace('suite hidden', 'suite');\n\
}\n\
}\n\
\n\
/**\n\
* Set `el` text to `str`.\n\
*/\n\
\n\
function text(el, str) {\n\
if (el.textContent) {\n\
el.textContent = str;\n\
} else {\n\
el.innerText = str;\n\
}\n\
}\n\
\n\
/**\n\
* Listen on `event` with callback `fn`.\n\
*/\n\
\n\
function on(el, event, fn) {\n\
if (el.addEventListener) {\n\
el.addEventListener(event, fn, false);\n\
} else {\n\
el.attachEvent('on' + event, fn);\n\
}\n\
}\n\
\n\
}); // module: reporters/html.js\n\
\n\
require.register(\"reporters/index.js\", function(module, exports, require){\n\
\n\
exports.Base = require(\"undefined\");\n\
exports.Dot = require(\"undefined\");\n\
exports.Doc = require(\"undefined\");\n\
exports.TAP = require(\"undefined\");\n\
exports.JSON = require(\"undefined\");\n\
exports.HTML = require(\"undefined\");\n\
exports.List = require(\"undefined\");\n\
exports.Min = require(\"undefined\");\n\
exports.Spec = require(\"undefined\");\n\
exports.Nyan = require(\"undefined\");\n\
exports.XUnit = require(\"undefined\");\n\
exports.Markdown = require(\"undefined\");\n\
exports.Progress = require(\"undefined\");\n\
exports.Landing = require(\"undefined\");\n\
exports.JSONCov = require(\"undefined\");\n\
exports.HTMLCov = require(\"undefined\");\n\
exports.JSONStream = require(\"undefined\");\n\
\n\
}); // module: reporters/index.js\n\
\n\
require.register(\"reporters/json-cov.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\");\n\
\n\
/**\n\
* Expose `JSONCov`.\n\
*/\n\
\n\
exports = module.exports = JSONCov;\n\
\n\
/**\n\
* Initialize a new `JsCoverage` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @param {Boolean} output\n\
* @api public\n\
*/\n\
\n\
function JSONCov(runner, output) {\n\
var self = this\n\
, output = 1 == arguments.length ? true : output;\n\
\n\
Base.call(this, runner);\n\
\n\
var tests = []\n\
, failures = []\n\
, passes = [];\n\
\n\
runner.on('test end', function(test){\n\
tests.push(test);\n\
});\n\
\n\
runner.on('pass', function(test){\n\
passes.push(test);\n\
});\n\
\n\
runner.on('fail', function(test){\n\
failures.push(test);\n\
});\n\
\n\
runner.on('end', function(){\n\
var cov = global._$jscoverage || {};\n\
var result = self.cov = map(cov);\n\
result.stats = self.stats;\n\
result.tests = tests.map(clean);\n\
result.failures = failures.map(clean);\n\
result.passes = passes.map(clean);\n\
if (!output) return;\n\
process.stdout.write(JSON.stringify(result, null, 2 ));\n\
});\n\
}\n\
\n\
/**\n\
* Map jscoverage data to a JSON structure\n\
* suitable for reporting.\n\
*\n\
* @param {Object} cov\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function map(cov) {\n\
var ret = {\n\
instrumentation: 'node-jscoverage'\n\
, sloc: 0\n\
, hits: 0\n\
, misses: 0\n\
, coverage: 0\n\
, files: []\n\
};\n\
\n\
for (var filename in cov) {\n\
var data = coverage(filename, cov[filename]);\n\
ret.files.push(data);\n\
ret.hits += data.hits;\n\
ret.misses += data.misses;\n\
ret.sloc += data.sloc;\n\
}\n\
\n\
ret.files.sort(function(a, b) {\n\
return a.filename.localeCompare(b.filename);\n\
});\n\
\n\
if (ret.sloc > 0) {\n\
ret.coverage = (ret.hits / ret.sloc) * 100;\n\
}\n\
\n\
return ret;\n\
};\n\
\n\
/**\n\
* Map jscoverage data for a single source file\n\
* to a JSON structure suitable for reporting.\n\
*\n\
* @param {String} filename name of the source file\n\
* @param {Object} data jscoverage coverage data\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function coverage(filename, data) {\n\
var ret = {\n\
filename: filename,\n\
coverage: 0,\n\
hits: 0,\n\
misses: 0,\n\
sloc: 0,\n\
source: {}\n\
};\n\
\n\
data.source.forEach(function(line, num){\n\
num++;\n\
\n\
if (data[num] === 0) {\n\
ret.misses++;\n\
ret.sloc++;\n\
} else if (data[num] !== undefined) {\n\
ret.hits++;\n\
ret.sloc++;\n\
}\n\
\n\
ret.source[num] = {\n\
source: line\n\
, coverage: data[num] === undefined\n\
? ''\n\
: data[num]\n\
};\n\
});\n\
\n\
ret.coverage = ret.hits / ret.sloc * 100;\n\
\n\
return ret;\n\
}\n\
\n\
/**\n\
* Return a plain-object representation of `test`\n\
* free of cyclic properties etc.\n\
*\n\
* @param {Object} test\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function clean(test) {\n\
return {\n\
title: test.title\n\
, fullTitle: test.fullTitle()\n\
, duration: test.duration\n\
}\n\
}\n\
\n\
}); // module: reporters/json-cov.js\n\
\n\
require.register(\"reporters/json-stream.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `List`.\n\
*/\n\
\n\
exports = module.exports = List;\n\
\n\
/**\n\
* Initialize a new `List` test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function List(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, total = runner.total;\n\
\n\
runner.on('start', function(){\n\
console.log(JSON.stringify(['start', { total: total }]));\n\
});\n\
\n\
runner.on('pass', function(test){\n\
console.log(JSON.stringify(['pass', clean(test)]));\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
console.log(JSON.stringify(['fail', clean(test)]));\n\
});\n\
\n\
runner.on('end', function(){\n\
process.stdout.write(JSON.stringify(['end', self.stats]));\n\
});\n\
}\n\
\n\
/**\n\
* Return a plain-object representation of `test`\n\
* free of cyclic properties etc.\n\
*\n\
* @param {Object} test\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function clean(test) {\n\
return {\n\
title: test.title\n\
, fullTitle: test.fullTitle()\n\
, duration: test.duration\n\
}\n\
}\n\
}); // module: reporters/json-stream.js\n\
\n\
require.register(\"reporters/json.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `JSON`.\n\
*/\n\
\n\
exports = module.exports = JSONReporter;\n\
\n\
/**\n\
* Initialize a new `JSON` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function JSONReporter(runner) {\n\
var self = this;\n\
Base.call(this, runner);\n\
\n\
var tests = []\n\
, failures = []\n\
, passes = [];\n\
\n\
runner.on('test end', function(test){\n\
tests.push(test);\n\
});\n\
\n\
runner.on('pass', function(test){\n\
passes.push(test);\n\
});\n\
\n\
runner.on('fail', function(test){\n\
failures.push(test);\n\
});\n\
\n\
runner.on('end', function(){\n\
var obj = {\n\
stats: self.stats\n\
, tests: tests.map(clean)\n\
, failures: failures.map(clean)\n\
, passes: passes.map(clean)\n\
};\n\
\n\
process.stdout.write(JSON.stringify(obj, null, 2));\n\
});\n\
}\n\
\n\
/**\n\
* Return a plain-object representation of `test`\n\
* free of cyclic properties etc.\n\
*\n\
* @param {Object} test\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
function clean(test) {\n\
return {\n\
title: test.title\n\
, fullTitle: test.fullTitle()\n\
, duration: test.duration\n\
}\n\
}\n\
}); // module: reporters/json.js\n\
\n\
require.register(\"reporters/landing.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `Landing`.\n\
*/\n\
\n\
exports = module.exports = Landing;\n\
\n\
/**\n\
* Airplane color.\n\
*/\n\
\n\
Base.colors.plane = 0;\n\
\n\
/**\n\
* Airplane crash color.\n\
*/\n\
\n\
Base.colors['plane crash'] = 31;\n\
\n\
/**\n\
* Runway color.\n\
*/\n\
\n\
Base.colors.runway = 90;\n\
\n\
/**\n\
* Initialize a new `Landing` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Landing(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, width = Base.window.width * .75 | 0\n\
, total = runner.total\n\
, stream = process.stdout\n\
, plane = color('plane', '✈')\n\
, crashed = -1\n\
, n = 0;\n\
\n\
function runway() {\n\
var buf = Array(width).join('-');\n\
return ' ' + color('runway', buf);\n\
}\n\
\n\
runner.on('start', function(){\n\
stream.write('\\n\
');\n\
cursor.hide();\n\
});\n\
\n\
runner.on('test end', function(test){\n\
// check if the plane crashed\n\
var col = -1 == crashed\n\
? width * ++n / total | 0\n\
: crashed;\n\
\n\
// show the crash\n\
if ('failed' == test.state) {\n\
plane = color('plane crash', '✈');\n\
crashed = col;\n\
}\n\
\n\
// render landing strip\n\
stream.write('\\u001b[4F\\n\
\\n\
');\n\
stream.write(runway());\n\
stream.write('\\n\
');\n\
stream.write(color('runway', Array(col).join('⋅')));\n\
stream.write(plane)\n\
stream.write(color('runway', Array(width - col).join('⋅') + '\\n\
'));\n\
stream.write(runway());\n\
stream.write('\\u001b[0m');\n\
});\n\
\n\
runner.on('end', function(){\n\
cursor.show();\n\
console.log();\n\
self.epilogue();\n\
});\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
Landing.prototype = new F;\n\
Landing.prototype.constructor = Landing;\n\
\n\
}); // module: reporters/landing.js\n\
\n\
require.register(\"reporters/list.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `List`.\n\
*/\n\
\n\
exports = module.exports = List;\n\
\n\
/**\n\
* Initialize a new `List` test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function List(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, n = 0;\n\
\n\
runner.on('start', function(){\n\
console.log();\n\
});\n\
\n\
runner.on('test', function(test){\n\
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));\n\
});\n\
\n\
runner.on('pending', function(test){\n\
var fmt = color('checkmark', ' -')\n\
+ color('pending', ' %s');\n\
console.log(fmt, test.fullTitle());\n\
});\n\
\n\
runner.on('pass', function(test){\n\
var fmt = color('checkmark', ' '+Base.symbols.dot)\n\
+ color('pass', ' %s: ')\n\
+ color(test.speed, '%dms');\n\
cursor.CR();\n\
console.log(fmt, test.fullTitle(), test.duration);\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
cursor.CR();\n\
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());\n\
});\n\
\n\
runner.on('end', self.epilogue.bind(self));\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
List.prototype = new F;\n\
List.prototype.constructor = List;\n\
\n\
\n\
}); // module: reporters/list.js\n\
\n\
require.register(\"reporters/markdown.js\", function(module, exports, require){\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, utils = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Markdown`.\n\
*/\n\
\n\
exports = module.exports = Markdown;\n\
\n\
/**\n\
* Initialize a new `Markdown` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Markdown(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, level = 0\n\
, buf = '';\n\
\n\
function title(str) {\n\
return Array(level).join('#') + ' ' + str;\n\
}\n\
\n\
function indent() {\n\
return Array(level).join(' ');\n\
}\n\
\n\
function mapTOC(suite, obj) {\n\
var ret = obj;\n\
obj = obj[suite.title] = obj[suite.title] || { suite: suite };\n\
suite.suites.forEach(function(suite){\n\
mapTOC(suite, obj);\n\
});\n\
return ret;\n\
}\n\
\n\
function stringifyTOC(obj, level) {\n\
++level;\n\
var buf = '';\n\
var link;\n\
for (var key in obj) {\n\
if ('suite' == key) continue;\n\
if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\\n\
';\n\
if (key) buf += Array(level).join(' ') + link;\n\
buf += stringifyTOC(obj[key], level);\n\
}\n\
--level;\n\
return buf;\n\
}\n\
\n\
function generateTOC(suite) {\n\
var obj = mapTOC(suite, {});\n\
return stringifyTOC(obj, 0);\n\
}\n\
\n\
generateTOC(runner.suite);\n\
\n\
runner.on('suite', function(suite){\n\
++level;\n\
var slug = utils.slug(suite.fullTitle());\n\
buf += '<a name=\"' + slug + '\"></a>' + '\\n\
';\n\
buf += title(suite.title) + '\\n\
';\n\
});\n\
\n\
runner.on('suite end', function(suite){\n\
--level;\n\
});\n\
\n\
runner.on('pass', function(test){\n\
var code = utils.clean(test.fn.toString());\n\
buf += test.title + '.\\n\
';\n\
buf += '\\n\
```js\\n\
';\n\
buf += code + '\\n\
';\n\
buf += '```\\n\
\\n\
';\n\
});\n\
\n\
runner.on('end', function(){\n\
process.stdout.write('# TOC\\n\
');\n\
process.stdout.write(generateTOC(runner.suite));\n\
process.stdout.write(buf);\n\
});\n\
}\n\
}); // module: reporters/markdown.js\n\
\n\
require.register(\"reporters/min.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Min`.\n\
*/\n\
\n\
exports = module.exports = Min;\n\
\n\
/**\n\
* Initialize a new `Min` minimal test reporter (best used with --watch).\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Min(runner) {\n\
Base.call(this, runner);\n\
\n\
runner.on('start', function(){\n\
// clear screen\n\
process.stdout.write('\\u001b[2J');\n\
// set cursor position\n\
process.stdout.write('\\u001b[1;3H');\n\
});\n\
\n\
runner.on('end', this.epilogue.bind(this));\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
Min.prototype = new F;\n\
Min.prototype.constructor = Min;\n\
\n\
\n\
}); // module: reporters/min.js\n\
\n\
require.register(\"reporters/nyan.js\", function(module, exports, require){\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `Dot`.\n\
*/\n\
\n\
exports = module.exports = NyanCat;\n\
\n\
/**\n\
* Initialize a new `Dot` matrix test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function NyanCat(runner) {\n\
Base.call(this, runner);\n\
var self = this\n\
, stats = this.stats\n\
, width = Base.window.width * .75 | 0\n\
, rainbowColors = this.rainbowColors = self.generateColors()\n\
, colorIndex = this.colorIndex = 0\n\
, numerOfLines = this.numberOfLines = 4\n\
, trajectories = this.trajectories = [[], [], [], []]\n\
, nyanCatWidth = this.nyanCatWidth = 11\n\
, trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)\n\
, scoreboardWidth = this.scoreboardWidth = 5\n\
, tick = this.tick = 0\n\
, n = 0;\n\
\n\
runner.on('start', function(){\n\
Base.cursor.hide();\n\
self.draw();\n\
});\n\
\n\
runner.on('pending', function(test){\n\
self.draw();\n\
});\n\
\n\
runner.on('pass', function(test){\n\
self.draw();\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
self.draw();\n\
});\n\
\n\
runner.on('end', function(){\n\
Base.cursor.show();\n\
for (var i = 0; i < self.numberOfLines; i++) write('\\n\
');\n\
self.epilogue();\n\
});\n\
}\n\
\n\
/**\n\
* Draw the nyan cat\n\
*\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.draw = function(){\n\
this.appendRainbow();\n\
this.drawScoreboard();\n\
this.drawRainbow();\n\
this.drawNyanCat();\n\
this.tick = !this.tick;\n\
};\n\
\n\
/**\n\
* Draw the \"scoreboard\" showing the number\n\
* of passes, failures and pending tests.\n\
*\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.drawScoreboard = function(){\n\
var stats = this.stats;\n\
var colors = Base.colors;\n\
\n\
function draw(color, n) {\n\
write(' ');\n\
write('\\u001b[' + color + 'm' + n + '\\u001b[0m');\n\
write('\\n\
');\n\
}\n\
\n\
draw(colors.green, stats.passes);\n\
draw(colors.fail, stats.failures);\n\
draw(colors.pending, stats.pending);\n\
write('\\n\
');\n\
\n\
this.cursorUp(this.numberOfLines);\n\
};\n\
\n\
/**\n\
* Append the rainbow.\n\
*\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.appendRainbow = function(){\n\
var segment = this.tick ? '_' : '-';\n\
var rainbowified = this.rainbowify(segment);\n\
\n\
for (var index = 0; index < this.numberOfLines; index++) {\n\
var trajectory = this.trajectories[index];\n\
if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();\n\
trajectory.push(rainbowified);\n\
}\n\
};\n\
\n\
/**\n\
* Draw the rainbow.\n\
*\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.drawRainbow = function(){\n\
var self = this;\n\
\n\
this.trajectories.forEach(function(line, index) {\n\
write('\\u001b[' + self.scoreboardWidth + 'C');\n\
write(line.join(''));\n\
write('\\n\
');\n\
});\n\
\n\
this.cursorUp(this.numberOfLines);\n\
};\n\
\n\
/**\n\
* Draw the nyan cat\n\
*\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.drawNyanCat = function() {\n\
var self = this;\n\
var startWidth = this.scoreboardWidth + this.trajectories[0].length;\n\
var color = '\\u001b[' + startWidth + 'C';\n\
var padding = '';\n\
\n\
write(color);\n\
write('_,------,');\n\
write('\\n\
');\n\
\n\
write(color);\n\
padding = self.tick ? ' ' : ' ';\n\
write('_|' + padding + '/\\\\_/\\\\ ');\n\
write('\\n\
');\n\
\n\
write(color);\n\
padding = self.tick ? '_' : '__';\n\
var tail = self.tick ? '~' : '^';\n\
var face;\n\
write(tail + '|' + padding + this.face() + ' ');\n\
write('\\n\
');\n\
\n\
write(color);\n\
padding = self.tick ? ' ' : ' ';\n\
write(padding + '\"\" \"\" ');\n\
write('\\n\
');\n\
\n\
this.cursorUp(this.numberOfLines);\n\
};\n\
\n\
/**\n\
* Draw nyan cat face.\n\
*\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.face = function() {\n\
var stats = this.stats;\n\
if (stats.failures) {\n\
return '( x .x)';\n\
} else if (stats.pending) {\n\
return '( o .o)';\n\
} else if(stats.passes) {\n\
return '( ^ .^)';\n\
} else {\n\
return '( - .-)';\n\
}\n\
}\n\
\n\
/**\n\
* Move cursor up `n`.\n\
*\n\
* @param {Number} n\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.cursorUp = function(n) {\n\
write('\\u001b[' + n + 'A');\n\
};\n\
\n\
/**\n\
* Move cursor down `n`.\n\
*\n\
* @param {Number} n\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.cursorDown = function(n) {\n\
write('\\u001b[' + n + 'B');\n\
};\n\
\n\
/**\n\
* Generate rainbow colors.\n\
*\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.generateColors = function(){\n\
var colors = [];\n\
\n\
for (var i = 0; i < (6 * 7); i++) {\n\
var pi3 = Math.floor(Math.PI / 3);\n\
var n = (i * (1.0 / 6));\n\
var r = Math.floor(3 * Math.sin(n) + 3);\n\
var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);\n\
var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);\n\
colors.push(36 * r + 6 * g + b + 16);\n\
}\n\
\n\
return colors;\n\
};\n\
\n\
/**\n\
* Apply rainbow to the given `str`.\n\
*\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
NyanCat.prototype.rainbowify = function(str){\n\
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];\n\
this.colorIndex += 1;\n\
return '\\u001b[38;5;' + color + 'm' + str + '\\u001b[0m';\n\
};\n\
\n\
/**\n\
* Stdout helper.\n\
*/\n\
\n\
function write(string) {\n\
process.stdout.write(string);\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
NyanCat.prototype = new F;\n\
NyanCat.prototype.constructor = NyanCat;\n\
\n\
\n\
}); // module: reporters/nyan.js\n\
\n\
require.register(\"reporters/progress.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `Progress`.\n\
*/\n\
\n\
exports = module.exports = Progress;\n\
\n\
/**\n\
* General progress bar color.\n\
*/\n\
\n\
Base.colors.progress = 90;\n\
\n\
/**\n\
* Initialize a new `Progress` bar test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @param {Object} options\n\
* @api public\n\
*/\n\
\n\
function Progress(runner, options) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, options = options || {}\n\
, stats = this.stats\n\
, width = Base.window.width * .50 | 0\n\
, total = runner.total\n\
, complete = 0\n\
, max = Math.max;\n\
\n\
// default chars\n\
options.open = options.open || '[';\n\
options.complete = options.complete || '▬';\n\
options.incomplete = options.incomplete || Base.symbols.dot;\n\
options.close = options.close || ']';\n\
options.verbose = false;\n\
\n\
// tests started\n\
runner.on('start', function(){\n\
console.log();\n\
cursor.hide();\n\
});\n\
\n\
// tests complete\n\
runner.on('test end', function(){\n\
complete++;\n\
var incomplete = total - complete\n\
, percent = complete / total\n\
, n = width * percent | 0\n\
, i = width - n;\n\
\n\
cursor.CR();\n\
process.stdout.write('\\u001b[J');\n\
process.stdout.write(color('progress', ' ' + options.open));\n\
process.stdout.write(Array(n).join(options.complete));\n\
process.stdout.write(Array(i).join(options.incomplete));\n\
process.stdout.write(color('progress', options.close));\n\
if (options.verbose) {\n\
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));\n\
}\n\
});\n\
\n\
// tests are complete, output some stats\n\
// and the failures if any\n\
runner.on('end', function(){\n\
cursor.show();\n\
console.log();\n\
self.epilogue();\n\
});\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
Progress.prototype = new F;\n\
Progress.prototype.constructor = Progress;\n\
\n\
\n\
}); // module: reporters/progress.js\n\
\n\
require.register(\"reporters/spec.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `Spec`.\n\
*/\n\
\n\
exports = module.exports = Spec;\n\
\n\
/**\n\
* Initialize a new `Spec` test reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function Spec(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, indents = 0\n\
, n = 0;\n\
\n\
function indent() {\n\
return Array(indents).join(' ')\n\
}\n\
\n\
runner.on('start', function(){\n\
console.log();\n\
});\n\
\n\
runner.on('suite', function(suite){\n\
++indents;\n\
console.log(color('suite', '%s%s'), indent(), suite.title);\n\
});\n\
\n\
runner.on('suite end', function(suite){\n\
--indents;\n\
if (1 == indents) console.log();\n\
});\n\
\n\
runner.on('pending', function(test){\n\
var fmt = indent() + color('pending', ' - %s');\n\
console.log(fmt, test.title);\n\
});\n\
\n\
runner.on('pass', function(test){\n\
if ('fast' == test.speed) {\n\
var fmt = indent()\n\
+ color('checkmark', ' ' + Base.symbols.ok)\n\
+ color('pass', ' %s ');\n\
cursor.CR();\n\
console.log(fmt, test.title);\n\
} else {\n\
var fmt = indent()\n\
+ color('checkmark', ' ' + Base.symbols.ok)\n\
+ color('pass', ' %s ')\n\
+ color(test.speed, '(%dms)');\n\
cursor.CR();\n\
console.log(fmt, test.title, test.duration);\n\
}\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
cursor.CR();\n\
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);\n\
});\n\
\n\
runner.on('end', self.epilogue.bind(self));\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
Spec.prototype = new F;\n\
Spec.prototype.constructor = Spec;\n\
\n\
\n\
}); // module: reporters/spec.js\n\
\n\
require.register(\"reporters/tap.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, cursor = Base.cursor\n\
, color = Base.color;\n\
\n\
/**\n\
* Expose `TAP`.\n\
*/\n\
\n\
exports = module.exports = TAP;\n\
\n\
/**\n\
* Initialize a new `TAP` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function TAP(runner) {\n\
Base.call(this, runner);\n\
\n\
var self = this\n\
, stats = this.stats\n\
, n = 1\n\
, passes = 0\n\
, failures = 0;\n\
\n\
runner.on('start', function(){\n\
var total = runner.grepTotal(runner.suite);\n\
console.log('%d..%d', 1, total);\n\
});\n\
\n\
runner.on('test end', function(){\n\
++n;\n\
});\n\
\n\
runner.on('pending', function(test){\n\
console.log('ok %d %s # SKIP -', n, title(test));\n\
});\n\
\n\
runner.on('pass', function(test){\n\
passes++;\n\
console.log('ok %d %s', n, title(test));\n\
});\n\
\n\
runner.on('fail', function(test, err){\n\
failures++;\n\
console.log('not ok %d %s', n, title(test));\n\
if (err.stack) console.log(err.stack.replace(/^/gm, ' '));\n\
});\n\
\n\
runner.on('end', function(){\n\
console.log('# tests ' + (passes + failures));\n\
console.log('# pass ' + passes);\n\
console.log('# fail ' + failures);\n\
});\n\
}\n\
\n\
/**\n\
* Return a TAP-safe title of `test`\n\
*\n\
* @param {Object} test\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function title(test) {\n\
return test.fullTitle().replace(/#/g, '');\n\
}\n\
\n\
}); // module: reporters/tap.js\n\
\n\
require.register(\"reporters/xunit.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Base = require(\"undefined\")\n\
, utils = require(\"undefined\")\n\
, escape = utils.escape;\n\
\n\
/**\n\
* Save timer references to avoid Sinon interfering (see GH-237).\n\
*/\n\
\n\
var Date = global.Date\n\
, setTimeout = global.setTimeout\n\
, setInterval = global.setInterval\n\
, clearTimeout = global.clearTimeout\n\
, clearInterval = global.clearInterval;\n\
\n\
/**\n\
* Expose `XUnit`.\n\
*/\n\
\n\
exports = module.exports = XUnit;\n\
\n\
/**\n\
* Initialize a new `XUnit` reporter.\n\
*\n\
* @param {Runner} runner\n\
* @api public\n\
*/\n\
\n\
function XUnit(runner) {\n\
Base.call(this, runner);\n\
var stats = this.stats\n\
, tests = []\n\
, self = this;\n\
\n\
runner.on('pending', function(test){\n\
tests.push(test);\n\
});\n\
\n\
runner.on('pass', function(test){\n\
tests.push(test);\n\
});\n\
\n\
runner.on('fail', function(test){\n\
tests.push(test);\n\
});\n\
\n\
runner.on('end', function(){\n\
console.log(tag('testsuite', {\n\
name: 'Mocha Tests'\n\
, tests: stats.tests\n\
, failures: stats.failures\n\
, errors: stats.failures\n\
, skipped: stats.tests - stats.failures - stats.passes\n\
, timestamp: (new Date).toUTCString()\n\
, time: (stats.duration / 1000) || 0\n\
}, false));\n\
\n\
tests.forEach(test);\n\
console.log('</testsuite>');\n\
});\n\
}\n\
\n\
/**\n\
* Inherit from `Base.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Base.prototype;\n\
XUnit.prototype = new F;\n\
XUnit.prototype.constructor = XUnit;\n\
\n\
\n\
/**\n\
* Output tag for the given `test.`\n\
*/\n\
\n\
function test(test) {\n\
var attrs = {\n\
classname: test.parent.fullTitle()\n\
, name: test.title\n\
, time: (test.duration / 1000) || 0\n\
};\n\
\n\
if ('failed' == test.state) {\n\
var err = test.err;\n\
attrs.message = escape(err.message);\n\
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));\n\
} else if (test.pending) {\n\
console.log(tag('testcase', attrs, false, tag('skipped', {}, true)));\n\
} else {\n\
console.log(tag('testcase', attrs, true) );\n\
}\n\
}\n\
\n\
/**\n\
* HTML tag helper.\n\
*/\n\
\n\
function tag(name, attrs, close, content) {\n\
var end = close ? '/>' : '>'\n\
, pairs = []\n\
, tag;\n\
\n\
for (var key in attrs) {\n\
pairs.push(key + '=\"' + escape(attrs[key]) + '\"');\n\
}\n\
\n\
tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;\n\
if (content) tag += content + '</' + name + end;\n\
return tag;\n\
}\n\
\n\
/**\n\
* Return cdata escaped CDATA `str`.\n\
*/\n\
\n\
function cdata(str) {\n\
return '<![CDATA[' + escape(str) + ']]>';\n\
}\n\
\n\
}); // module: reporters/xunit.js\n\
\n\
require.register(\"runnable.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var EventEmitter = require(\"browser/events\").EventEmitter\n\
, debug = require(\"browser/debug\")('mocha:runnable')\n\
, milliseconds = require(\"undefined\");\n\
\n\
/**\n\
* Save timer references to avoid Sinon interfering (see GH-237).\n\
*/\n\
\n\
var Date = global.Date\n\
, setTimeout = global.setTimeout\n\
, setInterval = global.setInterval\n\
, clearTimeout = global.clearTimeout\n\
, clearInterval = global.clearInterval;\n\
\n\
/**\n\
* Object#toString().\n\
*/\n\
\n\
var toString = Object.prototype.toString;\n\
\n\
/**\n\
* Expose `Runnable`.\n\
*/\n\
\n\
module.exports = Runnable;\n\
\n\
/**\n\
* Initialize a new `Runnable` with the given `title` and callback `fn`.\n\
*\n\
* @param {String} title\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
function Runnable(title, fn) {\n\
this.title = title;\n\
this.fn = fn;\n\
this.async = fn && fn.length;\n\
this.sync = ! this.async;\n\
this._timeout = 2000;\n\
this._slow = 75;\n\
this.timedOut = false;\n\
}\n\
\n\
/**\n\
* Inherit from `EventEmitter.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = EventEmitter.prototype;\n\
Runnable.prototype = new F;\n\
Runnable.prototype.constructor = Runnable;\n\
\n\
\n\
/**\n\
* Set & get timeout `ms`.\n\
*\n\
* @param {Number|String} ms\n\
* @return {Runnable|Number} ms or self\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.timeout = function(ms){\n\
if (0 == arguments.length) return this._timeout;\n\
if ('string' == typeof ms) ms = milliseconds(ms);\n\
debug('timeout %d', ms);\n\
this._timeout = ms;\n\
if (this.timer) this.resetTimeout();\n\
return this;\n\
};\n\
\n\
/**\n\
* Set & get slow `ms`.\n\
*\n\
* @param {Number|String} ms\n\
* @return {Runnable|Number} ms or self\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.slow = function(ms){\n\
if (0 === arguments.length) return this._slow;\n\
if ('string' == typeof ms) ms = milliseconds(ms);\n\
debug('timeout %d', ms);\n\
this._slow = ms;\n\
return this;\n\
};\n\
\n\
/**\n\
* Return the full title generated by recursively\n\
* concatenating the parent's full title.\n\
*\n\
* @return {String}\n\
* @api public\n\
*/\n\
\n\
Runnable.prototype.fullTitle = function(){\n\
return this.parent.fullTitle() + ' ' + this.title;\n\
};\n\
\n\
/**\n\
* Clear the timeout.\n\
*\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.clearTimeout = function(){\n\
clearTimeout(this.timer);\n\
};\n\
\n\
/**\n\
* Inspect the runnable void of private properties.\n\
*\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.inspect = function(){\n\
return JSON.stringify(this, function(key, val){\n\
if ('_' == key[0]) return;\n\
if ('parent' == key) return '#<Suite>';\n\
if ('ctx' == key) return '#<Context>';\n\
return val;\n\
}, 2);\n\
};\n\
\n\
/**\n\
* Reset the timeout.\n\
*\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.resetTimeout = function(){\n\
var self = this;\n\
var ms = this.timeout() || 1e9;\n\
\n\
this.clearTimeout();\n\
this.timer = setTimeout(function(){\n\
self.callback(new Error('timeout of ' + ms + 'ms exceeded'));\n\
self.timedOut = true;\n\
}, ms);\n\
};\n\
\n\
/**\n\
* Whitelist these globals for this test run\n\
*\n\
* @api private\n\
*/\n\
Runnable.prototype.globals = function(arr){\n\
var self = this;\n\
this._allowedGlobals = arr;\n\
};\n\
\n\
/**\n\
* Run the test and invoke `fn(err)`.\n\
*\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runnable.prototype.run = function(fn){\n\
var self = this\n\
, ms = this.timeout()\n\
, start = new Date\n\
, ctx = this.ctx\n\
, finished\n\
, emitted;\n\
\n\
if (ctx) ctx.runnable(this);\n\
\n\
// called multiple times\n\
function multiple(err) {\n\
if (emitted) return;\n\
emitted = true;\n\
self.emit('error', err || new Error('done() called multiple times'));\n\
}\n\
\n\
// finished\n\
function done(err) {\n\
if (self.timedOut) return;\n\
if (finished) return multiple(err);\n\
self.clearTimeout();\n\
self.duration = new Date - start;\n\
finished = true;\n\
fn(err);\n\
}\n\
\n\
// for .resetTimeout()\n\
this.callback = done;\n\
\n\
// explicit async with `done` argument\n\
if (this.async) {\n\
this.resetTimeout();\n\
\n\
try {\n\
this.fn.call(ctx, function(err){\n\
if (err instanceof Error || toString.call(err) === \"[object Error]\") return done(err);\n\
if (null != err) return done(new Error('done() invoked with non-Error: ' + err));\n\
done();\n\
});\n\
} catch (err) {\n\
done(err);\n\
}\n\
return;\n\
}\n\
\n\
if (this.asyncOnly) {\n\
return done(new Error('--async-only option in use without declaring `done()`'));\n\
}\n\
\n\
// sync or promise-returning\n\
try {\n\
if (this.pending) {\n\
done();\n\
} else {\n\
callFn(this.fn);\n\
}\n\
} catch (err) {\n\
done(err);\n\
}\n\
\n\
function callFn(fn) {\n\
var result = fn.call(ctx);\n\
if (result && typeof result.then === 'function') {\n\
self.resetTimeout();\n\
result.then(function(){ done() }, done);\n\
} else {\n\
done();\n\
}\n\
}\n\
};\n\
\n\
}); // module: runnable.js\n\
\n\
require.register(\"runner.js\", function(module, exports, require){\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var EventEmitter = require(\"browser/events\").EventEmitter\n\
, debug = require(\"browser/debug\")('mocha:runner')\n\
, Test = require(\"undefined\")\n\
, utils = require(\"undefined\")\n\
, filter = utils.filter\n\
, keys = utils.keys;\n\
\n\
/**\n\
* Non-enumerable globals.\n\
*/\n\
\n\
var globals = [\n\
'setTimeout',\n\
'clearTimeout',\n\
'setInterval',\n\
'clearInterval',\n\
'XMLHttpRequest',\n\
'Date'\n\
];\n\
\n\
/**\n\
* Expose `Runner`.\n\
*/\n\
\n\
module.exports = Runner;\n\
\n\
/**\n\
* Initialize a `Runner` for the given `suite`.\n\
*\n\
* Events:\n\
*\n\
* - `start` execution started\n\
* - `end` execution complete\n\
* - `suite` (suite) test suite execution started\n\
* - `suite end` (suite) all tests (and sub-suites) have finished\n\
* - `test` (test) test execution started\n\
* - `test end` (test) test completed\n\
* - `hook` (hook) hook execution started\n\
* - `hook end` (hook) hook complete\n\
* - `pass` (test) test passed\n\
* - `fail` (test, err) test failed\n\
* - `pending` (test) test pending\n\
*\n\
* @api public\n\
*/\n\
\n\
function Runner(suite) {\n\
var self = this;\n\
this._globals = [];\n\
this._abort = false;\n\
this.suite = suite;\n\
this.total = suite.total();\n\
this.failures = 0;\n\
this.on('test end', function(test){ self.checkGlobals(test); });\n\
this.on('hook end', function(hook){ self.checkGlobals(hook); });\n\
this.grep(/.*/);\n\
this.globals(this.globalProps().concat(extraGlobals()));\n\
}\n\
\n\
/**\n\
* Wrapper for setImmediate, process.nextTick, or browser polyfill.\n\
*\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.immediately = global.setImmediate || process.nextTick;\n\
\n\
/**\n\
* Inherit from `EventEmitter.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = EventEmitter.prototype;\n\
Runner.prototype = new F;\n\
Runner.prototype.constructor = Runner;\n\
\n\
\n\
/**\n\
* Run tests with full titles matching `re`. Updates runner.total\n\
* with number of tests matched.\n\
*\n\
* @param {RegExp} re\n\
* @param {Boolean} invert\n\
* @return {Runner} for chaining\n\
* @api public\n\
*/\n\
\n\
Runner.prototype.grep = function(re, invert){\n\
debug('grep %s', re);\n\
this._grep = re;\n\
this._invert = invert;\n\
this.total = this.grepTotal(this.suite);\n\
return this;\n\
};\n\
\n\
/**\n\
* Returns the number of tests matching the grep search for the\n\
* given suite.\n\
*\n\
* @param {Suite} suite\n\
* @return {Number}\n\
* @api public\n\
*/\n\
\n\
Runner.prototype.grepTotal = function(suite) {\n\
var self = this;\n\
var total = 0;\n\
\n\
suite.eachTest(function(test){\n\
var match = self._grep.test(test.fullTitle());\n\
if (self._invert) match = !match;\n\
if (match) total++;\n\
});\n\
\n\
return total;\n\
};\n\
\n\
/**\n\
* Return a list of global properties.\n\
*\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.globalProps = function() {\n\
var props = utils.keys(global);\n\
\n\
// non-enumerables\n\
for (var i = 0; i < globals.length; ++i) {\n\
if (~utils.indexOf(props, globals[i])) continue;\n\
props.push(globals[i]);\n\
}\n\
\n\
return props;\n\
};\n\
\n\
/**\n\
* Allow the given `arr` of globals.\n\
*\n\
* @param {Array} arr\n\
* @return {Runner} for chaining\n\
* @api public\n\
*/\n\
\n\
Runner.prototype.globals = function(arr){\n\
if (0 == arguments.length) return this._globals;\n\
debug('globals %j', arr);\n\
this._globals = this._globals.concat(arr);\n\
return this;\n\
};\n\
\n\
/**\n\
* Check for global variable leaks.\n\
*\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.checkGlobals = function(test){\n\
if (this.ignoreLeaks) return;\n\
var ok = this._globals;\n\
\n\
var globals = this.globalProps();\n\
var isNode = process.kill;\n\
var leaks;\n\
\n\
if (test) {\n\
ok = ok.concat(test._allowedGlobals || []);\n\
}\n\
\n\
if(this.prevGlobalsLength == globals.length) return;\n\
this.prevGlobalsLength = globals.length;\n\
\n\
leaks = filterLeaks(ok, globals);\n\
this._globals = this._globals.concat(leaks);\n\
\n\
if (leaks.length > 1) {\n\
this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));\n\
} else if (leaks.length) {\n\
this.fail(test, new Error('global leak detected: ' + leaks[0]));\n\
}\n\
};\n\
\n\
/**\n\
* Fail the given `test`.\n\
*\n\
* @param {Test} test\n\
* @param {Error} err\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.fail = function(test, err){\n\
++this.failures;\n\
test.state = 'failed';\n\
\n\
if ('string' == typeof err) {\n\
err = new Error('the string \"' + err + '\" was thrown, throw an Error :)');\n\
}\n\
\n\
this.emit('fail', test, err);\n\
};\n\
\n\
/**\n\
* Fail the given `hook` with `err`.\n\
*\n\
* Hook failures work in the following pattern:\n\
* - If bail, then exit\n\
* - Failed `before` hook skips all tests in a suite and subsuites,\n\
* but jumps to corresponding `after` hook\n\
* - Failed `before each` hook skips remaining tests in a\n\
* suite and jumps to corresponding `after each` hook,\n\
* which is run only once\n\
* - Failed `after` hook does not alter\n\
* execution order\n\
* - Failed `after each` hook skips remaining tests in a\n\
* suite and subsuites, but executes other `after each`\n\
* hooks\n\
*\n\
* @param {Hook} hook\n\
* @param {Error} err\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.failHook = function(hook, err){\n\
this.fail(hook, err);\n\
if (this.suite.bail()) {\n\
this.emit('end');\n\
}\n\
};\n\
\n\
/**\n\
* Run hook `name` callbacks and then invoke `fn()`.\n\
*\n\
* @param {String} name\n\
* @param {Function} function\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.hook = function(name, fn){\n\
var suite = this.suite\n\
, hooks = suite['_' + name]\n\
, self = this\n\
, timer;\n\
\n\
function next(i) {\n\
var hook = hooks[i];\n\
if (!hook) return fn();\n\
if (self.failures && suite.bail()) return fn();\n\
self.currentRunnable = hook;\n\
\n\
hook.ctx.currentTest = self.test;\n\
\n\
self.emit('hook', hook);\n\
\n\
hook.on('error', function(err){\n\
self.failHook(hook, err);\n\
});\n\
\n\
hook.run(function(err){\n\
hook.removeAllListeners('error');\n\
var testError = hook.error();\n\
if (testError) self.fail(self.test, testError);\n\
if (err) {\n\
self.failHook(hook, err);\n\
\n\
// stop executing hooks, notify callee of hook err\n\
return fn(err);\n\
}\n\
self.emit('hook end', hook);\n\
delete hook.ctx.currentTest;\n\
next(++i);\n\
});\n\
}\n\
\n\
Runner.immediately(function(){\n\
next(0);\n\
});\n\
};\n\
\n\
/**\n\
* Run hook `name` for the given array of `suites`\n\
* in order, and callback `fn(err, errSuite)`.\n\
*\n\
* @param {String} name\n\
* @param {Array} suites\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.hooks = function(name, suites, fn){\n\
var self = this\n\
, orig = this.suite;\n\
\n\
function next(suite) {\n\
self.suite = suite;\n\
\n\
if (!suite) {\n\
self.suite = orig;\n\
return fn();\n\
}\n\
\n\
self.hook(name, function(err){\n\
if (err) {\n\
var errSuite = self.suite;\n\
self.suite = orig;\n\
return fn(err, errSuite);\n\
}\n\
\n\
next(suites.pop());\n\
});\n\
}\n\
\n\
next(suites.pop());\n\
};\n\
\n\
/**\n\
* Run hooks from the top level down.\n\
*\n\
* @param {String} name\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.hookUp = function(name, fn){\n\
var suites = [this.suite].concat(this.parents()).reverse();\n\
this.hooks(name, suites, fn);\n\
};\n\
\n\
/**\n\
* Run hooks from the bottom up.\n\
*\n\
* @param {String} name\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.hookDown = function(name, fn){\n\
var suites = [this.suite].concat(this.parents());\n\
this.hooks(name, suites, fn);\n\
};\n\
\n\
/**\n\
* Return an array of parent Suites from\n\
* closest to furthest.\n\
*\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.parents = function(){\n\
var suite = this.suite\n\
, suites = [];\n\
while (suite = suite.parent) suites.push(suite);\n\
return suites;\n\
};\n\
\n\
/**\n\
* Run the current test and callback `fn(err)`.\n\
*\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.runTest = function(fn){\n\
var test = this.test\n\
, self = this;\n\
\n\
if (this.asyncOnly) test.asyncOnly = true;\n\
\n\
try {\n\
test.on('error', function(err){\n\
self.fail(test, err);\n\
});\n\
test.run(fn);\n\
} catch (err) {\n\
fn(err);\n\
}\n\
};\n\
\n\
/**\n\
* Run tests in the given `suite` and invoke\n\
* the callback `fn()` when complete.\n\
*\n\
* @param {Suite} suite\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.runTests = function(suite, fn){\n\
var self = this\n\
, tests = suite.tests.slice()\n\
, test;\n\
\n\
\n\
function hookErr(err, errSuite, after) {\n\
// before/after Each hook for errSuite failed:\n\
var orig = self.suite;\n\
\n\
// for failed 'after each' hook start from errSuite parent,\n\
// otherwise start from errSuite itself\n\
self.suite = after ? errSuite.parent : errSuite;\n\
\n\
if (self.suite) {\n\
// call hookUp afterEach\n\
self.hookUp('afterEach', function(err2, errSuite2) {\n\
self.suite = orig;\n\
// some hooks may fail even now\n\
if (err2) return hookErr(err2, errSuite2, true);\n\
// report error suite\n\
fn(errSuite);\n\
});\n\
} else {\n\
// there is no need calling other 'after each' hooks\n\
self.suite = orig;\n\
fn(errSuite);\n\
}\n\
}\n\
\n\
function next(err, errSuite) {\n\
// if we bail after first err\n\
if (self.failures && suite._bail) return fn();\n\
\n\
if (self._abort) return fn();\n\
\n\
if (err) return hookErr(err, errSuite, true);\n\
\n\
// next test\n\
test = tests.shift();\n\
\n\
// all done\n\
if (!test) return fn();\n\
\n\
// grep\n\
var match = self._grep.test(test.fullTitle());\n\
if (self._invert) match = !match;\n\
if (!match) return next();\n\
\n\
// pending\n\
if (test.pending) {\n\
self.emit('pending', test);\n\
self.emit('test end', test);\n\
return next();\n\
}\n\
\n\
// execute test and hook(s)\n\
self.emit('test', self.test = test);\n\
self.hookDown('beforeEach', function(err, errSuite){\n\
\n\
if (err) return hookErr(err, errSuite, false);\n\
\n\
self.currentRunnable = self.test;\n\
self.runTest(function(err){\n\
test = self.test;\n\
\n\
if (err) {\n\
self.fail(test, err);\n\
self.emit('test end', test);\n\
return self.hookUp('afterEach', next);\n\
}\n\
\n\
test.state = 'passed';\n\
self.emit('pass', test);\n\
self.emit('test end', test);\n\
self.hookUp('afterEach', next);\n\
});\n\
});\n\
}\n\
\n\
this.next = next;\n\
next();\n\
};\n\
\n\
/**\n\
* Run the given `suite` and invoke the\n\
* callback `fn()` when complete.\n\
*\n\
* @param {Suite} suite\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.runSuite = function(suite, fn){\n\
var total = this.grepTotal(suite)\n\
, self = this\n\
, i = 0;\n\
\n\
debug('run suite %s', suite.fullTitle());\n\
\n\
if (!total) return fn();\n\
\n\
this.emit('suite', this.suite = suite);\n\
\n\
function next(errSuite) {\n\
if (errSuite) {\n\
// current suite failed on a hook from errSuite\n\
if (errSuite == suite) {\n\
// if errSuite is current suite\n\
// continue to the next sibling suite\n\
return done();\n\
} else {\n\
// errSuite is among the parents of current suite\n\
// stop execution of errSuite and all sub-suites\n\
return done(errSuite);\n\
}\n\
}\n\
\n\
if (self._abort) return done();\n\
\n\
var curr = suite.suites[i++];\n\
if (!curr) return done();\n\
self.runSuite(curr, next);\n\
}\n\
\n\
function done(errSuite) {\n\
self.suite = suite;\n\
self.hook('afterAll', function(){\n\
self.emit('suite end', suite);\n\
fn(errSuite);\n\
});\n\
}\n\
\n\
this.hook('beforeAll', function(err){\n\
if (err) return done();\n\
self.runTests(suite, next);\n\
});\n\
};\n\
\n\
/**\n\
* Handle uncaught exceptions.\n\
*\n\
* @param {Error} err\n\
* @api private\n\
*/\n\
\n\
Runner.prototype.uncaught = function(err){\n\
debug('uncaught exception %s', err.message);\n\
var runnable = this.currentRunnable;\n\
if (!runnable || 'failed' == runnable.state) return;\n\
runnable.clearTimeout();\n\
err.uncaught = true;\n\
this.fail(runnable, err);\n\
\n\
// recover from test\n\
if ('test' == runnable.type) {\n\
this.emit('test end', runnable);\n\
this.hookUp('afterEach', this.next);\n\
return;\n\
}\n\
\n\
// bail on hooks\n\
this.emit('end');\n\
};\n\
\n\
/**\n\
* Run the root suite and invoke `fn(failures)`\n\
* on completion.\n\
*\n\
* @param {Function} fn\n\
* @return {Runner} for chaining\n\
* @api public\n\
*/\n\
\n\
Runner.prototype.run = function(fn){\n\
var self = this\n\
, fn = fn || function(){};\n\
\n\
function uncaught(err){\n\
self.uncaught(err);\n\
}\n\
\n\
debug('start');\n\
\n\
// callback\n\
this.on('end', function(){\n\
debug('end');\n\
process.removeListener('uncaughtException', uncaught);\n\
fn(self.failures);\n\
});\n\
\n\
// run suites\n\
this.emit('start');\n\
this.runSuite(this.suite, function(){\n\
debug('finished running');\n\
self.emit('end');\n\
});\n\
\n\
// uncaught exception\n\
process.on('uncaughtException', uncaught);\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Cleanly abort execution\n\
*\n\
* @return {Runner} for chaining\n\
* @api public\n\
*/\n\
Runner.prototype.abort = function(){\n\
debug('aborting');\n\
this._abort = true;\n\
}\n\
\n\
/**\n\
* Filter leaks with the given globals flagged as `ok`.\n\
*\n\
* @param {Array} ok\n\
* @param {Array} globals\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
function filterLeaks(ok, globals) {\n\
return filter(globals, function(key){\n\
// Firefox and Chrome exposes iframes as index inside the window object\n\
if (/^d+/.test(key)) return false;\n\
\n\
// in firefox\n\
// if runner runs in an iframe, this iframe's window.getInterface method not init at first\n\
// it is assigned in some seconds\n\
if (global.navigator && /^getInterface/.test(key)) return false;\n\
\n\
// an iframe could be approached by window[iframeIndex]\n\
// in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak\n\
if (global.navigator && /^\\d+/.test(key)) return false;\n\
\n\
// Opera and IE expose global variables for HTML element IDs (issue #243)\n\
if (/^mocha-/.test(key)) return false;\n\
\n\
var matched = filter(ok, function(ok){\n\
if (~ok.indexOf('*')) return 0 == key.indexOf(ok.split('*')[0]);\n\
return key == ok;\n\
});\n\
return matched.length == 0 && (!global.navigator || 'onerror' !== key);\n\
});\n\
}\n\
\n\
/**\n\
* Array of globals dependent on the environment.\n\
*\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
function extraGlobals() {\n\
if (typeof(process) === 'object' &&\n\
typeof(process.version) === 'string') {\n\
\n\
var nodeVersion = process.version.split('.').reduce(function(a, v) {\n\
return a << 8 | v;\n\
});\n\
\n\
// 'errno' was renamed to process._errno in v0.9.11.\n\
\n\
if (nodeVersion < 0x00090B) {\n\
return ['errno'];\n\
}\n\
}\n\
\n\
return [];\n\
}\n\
\n\
}); // module: runner.js\n\
\n\
require.register(\"suite.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var EventEmitter = require(\"browser/events\").EventEmitter\n\
, debug = require(\"browser/debug\")('mocha:suite')\n\
, milliseconds = require(\"undefined\")\n\
, utils = require(\"undefined\")\n\
, Hook = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Suite`.\n\
*/\n\
\n\
exports = module.exports = Suite;\n\
\n\
/**\n\
* Create a new `Suite` with the given `title`\n\
* and parent `Suite`. When a suite with the\n\
* same title is already present, that suite\n\
* is returned to provide nicer reporter\n\
* and more flexible meta-testing.\n\
*\n\
* @param {Suite} parent\n\
* @param {String} title\n\
* @return {Suite}\n\
* @api public\n\
*/\n\
\n\
exports.create = function(parent, title){\n\
var suite = new Suite(title, parent.ctx);\n\
suite.parent = parent;\n\
if (parent.pending) suite.pending = true;\n\
title = suite.fullTitle();\n\
parent.addSuite(suite);\n\
return suite;\n\
};\n\
\n\
/**\n\
* Initialize a new `Suite` with the given\n\
* `title` and `ctx`.\n\
*\n\
* @param {String} title\n\
* @param {Context} ctx\n\
* @api private\n\
*/\n\
\n\
function Suite(title, ctx) {\n\
this.title = title;\n\
this.ctx = ctx;\n\
this.suites = [];\n\
this.tests = [];\n\
this.pending = false;\n\
this._beforeEach = [];\n\
this._beforeAll = [];\n\
this._afterEach = [];\n\
this._afterAll = [];\n\
this.root = !title;\n\
this._timeout = 2000;\n\
this._slow = 75;\n\
this._bail = false;\n\
}\n\
\n\
/**\n\
* Inherit from `EventEmitter.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = EventEmitter.prototype;\n\
Suite.prototype = new F;\n\
Suite.prototype.constructor = Suite;\n\
\n\
\n\
/**\n\
* Return a clone of this `Suite`.\n\
*\n\
* @return {Suite}\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.clone = function(){\n\
var suite = new Suite(this.title);\n\
debug('clone');\n\
suite.ctx = this.ctx;\n\
suite.timeout(this.timeout());\n\
suite.slow(this.slow());\n\
suite.bail(this.bail());\n\
return suite;\n\
};\n\
\n\
/**\n\
* Set timeout `ms` or short-hand such as \"2s\".\n\
*\n\
* @param {Number|String} ms\n\
* @return {Suite|Number} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.timeout = function(ms){\n\
if (0 == arguments.length) return this._timeout;\n\
if ('string' == typeof ms) ms = milliseconds(ms);\n\
debug('timeout %d', ms);\n\
this._timeout = parseInt(ms, 10);\n\
return this;\n\
};\n\
\n\
/**\n\
* Set slow `ms` or short-hand such as \"2s\".\n\
*\n\
* @param {Number|String} ms\n\
* @return {Suite|Number} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.slow = function(ms){\n\
if (0 === arguments.length) return this._slow;\n\
if ('string' == typeof ms) ms = milliseconds(ms);\n\
debug('slow %d', ms);\n\
this._slow = ms;\n\
return this;\n\
};\n\
\n\
/**\n\
* Sets whether to bail after first error.\n\
*\n\
* @parma {Boolean} bail\n\
* @return {Suite|Number} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.bail = function(bail){\n\
if (0 == arguments.length) return this._bail;\n\
debug('bail %s', bail);\n\
this._bail = bail;\n\
return this;\n\
};\n\
\n\
/**\n\
* Run `fn(test[, done])` before running tests.\n\
*\n\
* @param {Function} fn\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.beforeAll = function(title, fn){\n\
if (this.pending) return this;\n\
if ('function' === typeof title) {\n\
fn = title;\n\
title = fn.name;\n\
}\n\
title = '\"before all\" hook' + (title ? ': ' + title : '');\n\
\n\
var hook = new Hook(title, fn);\n\
hook.parent = this;\n\
hook.timeout(this.timeout());\n\
hook.slow(this.slow());\n\
hook.ctx = this.ctx;\n\
this._beforeAll.push(hook);\n\
this.emit('beforeAll', hook);\n\
return this;\n\
};\n\
\n\
/**\n\
* Run `fn(test[, done])` after running tests.\n\
*\n\
* @param {Function} fn\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.afterAll = function(title, fn){\n\
if (this.pending) return this;\n\
if ('function' === typeof title) {\n\
fn = title;\n\
title = fn.name;\n\
}\n\
title = '\"after all\" hook' + (title ? ': ' + title : '');\n\
\n\
var hook = new Hook(title, fn);\n\
hook.parent = this;\n\
hook.timeout(this.timeout());\n\
hook.slow(this.slow());\n\
hook.ctx = this.ctx;\n\
this._afterAll.push(hook);\n\
this.emit('afterAll', hook);\n\
return this;\n\
};\n\
\n\
/**\n\
* Run `fn(test[, done])` before each test case.\n\
*\n\
* @param {Function} fn\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.beforeEach = function(title, fn){\n\
if (this.pending) return this;\n\
if ('function' === typeof title) {\n\
fn = title;\n\
title = fn.name;\n\
}\n\
title = '\"before each\" hook' + (title ? ': ' + title : '');\n\
\n\
var hook = new Hook(title, fn);\n\
hook.parent = this;\n\
hook.timeout(this.timeout());\n\
hook.slow(this.slow());\n\
hook.ctx = this.ctx;\n\
this._beforeEach.push(hook);\n\
this.emit('beforeEach', hook);\n\
return this;\n\
};\n\
\n\
/**\n\
* Run `fn(test[, done])` after each test case.\n\
*\n\
* @param {Function} fn\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.afterEach = function(title, fn){\n\
if (this.pending) return this;\n\
if ('function' === typeof title) {\n\
fn = title;\n\
title = fn.name;\n\
}\n\
title = '\"after each\" hook' + (title ? ': ' + title : '');\n\
\n\
var hook = new Hook(title, fn);\n\
hook.parent = this;\n\
hook.timeout(this.timeout());\n\
hook.slow(this.slow());\n\
hook.ctx = this.ctx;\n\
this._afterEach.push(hook);\n\
this.emit('afterEach', hook);\n\
return this;\n\
};\n\
\n\
/**\n\
* Add a test `suite`.\n\
*\n\
* @param {Suite} suite\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.addSuite = function(suite){\n\
suite.parent = this;\n\
suite.timeout(this.timeout());\n\
suite.slow(this.slow());\n\
suite.bail(this.bail());\n\
this.suites.push(suite);\n\
this.emit('suite', suite);\n\
return this;\n\
};\n\
\n\
/**\n\
* Add a `test` to this suite.\n\
*\n\
* @param {Test} test\n\
* @return {Suite} for chaining\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.addTest = function(test){\n\
test.parent = this;\n\
test.timeout(this.timeout());\n\
test.slow(this.slow());\n\
test.ctx = this.ctx;\n\
this.tests.push(test);\n\
this.emit('test', test);\n\
return this;\n\
};\n\
\n\
/**\n\
* Return the full title generated by recursively\n\
* concatenating the parent's full title.\n\
*\n\
* @return {String}\n\
* @api public\n\
*/\n\
\n\
Suite.prototype.fullTitle = function(){\n\
if (this.parent) {\n\
var full = this.parent.fullTitle();\n\
if (full) return full + ' ' + this.title;\n\
}\n\
return this.title;\n\
};\n\
\n\
/**\n\
* Return the total number of tests.\n\
*\n\
* @return {Number}\n\
* @api public\n\
*/\n\
\n\
Suite.prototype.total = function(){\n\
return utils.reduce(this.suites, function(sum, suite){\n\
return sum + suite.total();\n\
}, 0) + this.tests.length;\n\
};\n\
\n\
/**\n\
* Iterates through each suite recursively to find\n\
* all tests. Applies a function in the format\n\
* `fn(test)`.\n\
*\n\
* @param {Function} fn\n\
* @return {Suite}\n\
* @api private\n\
*/\n\
\n\
Suite.prototype.eachTest = function(fn){\n\
utils.forEach(this.tests, fn);\n\
utils.forEach(this.suites, function(suite){\n\
suite.eachTest(fn);\n\
});\n\
return this;\n\
};\n\
\n\
}); // module: suite.js\n\
\n\
require.register(\"test.js\", function(module, exports, require){\n\
\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var Runnable = require(\"undefined\");\n\
\n\
/**\n\
* Expose `Test`.\n\
*/\n\
\n\
module.exports = Test;\n\
\n\
/**\n\
* Initialize a new `Test` with the given `title` and callback `fn`.\n\
*\n\
* @param {String} title\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
function Test(title, fn) {\n\
Runnable.call(this, title, fn);\n\
this.pending = !fn;\n\
this.type = 'test';\n\
}\n\
\n\
/**\n\
* Inherit from `Runnable.prototype`.\n\
*/\n\
\n\
function F(){};\n\
F.prototype = Runnable.prototype;\n\
Test.prototype = new F;\n\
Test.prototype.constructor = Test;\n\
\n\
\n\
}); // module: test.js\n\
\n\
require.register(\"utils.js\", function(module, exports, require){\n\
/**\n\
* Module dependencies.\n\
*/\n\
\n\
var fs = require(\"browser/fs\")\n\
, path = require(\"browser/path\")\n\
, join = path.join\n\
, debug = require(\"browser/debug\")('mocha:watch');\n\
\n\
/**\n\
* Ignored directories.\n\
*/\n\
\n\
var ignore = ['node_modules', '.git'];\n\
\n\
/**\n\
* Escape special characters in the given string of html.\n\
*\n\
* @param {String} html\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
exports.escape = function(html){\n\
return String(html)\n\
.replace(/&/g, '&amp;')\n\
.replace(/\"/g, '&quot;')\n\
.replace(/</g, '&lt;')\n\
.replace(/>/g, '&gt;');\n\
};\n\
\n\
/**\n\
* Array#forEach (<=IE8)\n\
*\n\
* @param {Array} array\n\
* @param {Function} fn\n\
* @param {Object} scope\n\
* @api private\n\
*/\n\
\n\
exports.forEach = function(arr, fn, scope){\n\
for (var i = 0, l = arr.length; i < l; i++)\n\
fn.call(scope, arr[i], i);\n\
};\n\
\n\
/**\n\
* Array#map (<=IE8)\n\
*\n\
* @param {Array} array\n\
* @param {Function} fn\n\
* @param {Object} scope\n\
* @api private\n\
*/\n\
\n\
exports.map = function(arr, fn, scope){\n\
var result = [];\n\
for (var i = 0, l = arr.length; i < l; i++)\n\
result.push(fn.call(scope, arr[i], i));\n\
return result;\n\
};\n\
\n\
/**\n\
* Array#indexOf (<=IE8)\n\
*\n\
* @parma {Array} arr\n\
* @param {Object} obj to find index of\n\
* @param {Number} start\n\
* @api private\n\
*/\n\
\n\
exports.indexOf = function(arr, obj, start){\n\
for (var i = start || 0, l = arr.length; i < l; i++) {\n\
if (arr[i] === obj)\n\
return i;\n\
}\n\
return -1;\n\
};\n\
\n\
/**\n\
* Array#reduce (<=IE8)\n\
*\n\
* @param {Array} array\n\
* @param {Function} fn\n\
* @param {Object} initial value\n\
* @api private\n\
*/\n\
\n\
exports.reduce = function(arr, fn, val){\n\
var rval = val;\n\
\n\
for (var i = 0, l = arr.length; i < l; i++) {\n\
rval = fn(rval, arr[i], i, arr);\n\
}\n\
\n\
return rval;\n\
};\n\
\n\
/**\n\
* Array#filter (<=IE8)\n\
*\n\
* @param {Array} array\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
exports.filter = function(arr, fn){\n\
var ret = [];\n\
\n\
for (var i = 0, l = arr.length; i < l; i++) {\n\
var val = arr[i];\n\
if (fn(val, i, arr)) ret.push(val);\n\
}\n\
\n\
return ret;\n\
};\n\
\n\
/**\n\
* Object.keys (<=IE8)\n\
*\n\
* @param {Object} obj\n\
* @return {Array} keys\n\
* @api private\n\
*/\n\
\n\
exports.keys = Object.keys || function(obj) {\n\
var keys = []\n\
, has = Object.prototype.hasOwnProperty // for `window` on <=IE8\n\
\n\
for (var key in obj) {\n\
if (has.call(obj, key)) {\n\
keys.push(key);\n\
}\n\
}\n\
\n\
return keys;\n\
};\n\
\n\
/**\n\
* Watch the given `files` for changes\n\
* and invoke `fn(file)` on modification.\n\
*\n\
* @param {Array} files\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
exports.watch = function(files, fn){\n\
var options = { interval: 100 };\n\
files.forEach(function(file){\n\
debug('file %s', file);\n\
fs.watchFile(file, options, function(curr, prev){\n\
if (prev.mtime < curr.mtime) fn(file);\n\
});\n\
});\n\
};\n\
\n\
/**\n\
* Ignored files.\n\
*/\n\
\n\
function ignored(path){\n\
return !~ignore.indexOf(path);\n\
}\n\
\n\
/**\n\
* Lookup files in the given `dir`.\n\
*\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
exports.files = function(dir, ret){\n\
ret = ret || [];\n\
\n\
fs.readdirSync(dir)\n\
.filter(ignored)\n\
.forEach(function(path){\n\
path = join(dir, path);\n\
if (fs.statSync(path).isDirectory()) {\n\
exports.files(path, ret);\n\
} else if (path.match(/\\.(js|coffee|litcoffee|coffee.md)$/)) {\n\
ret.push(path);\n\
}\n\
});\n\
\n\
return ret;\n\
};\n\
\n\
/**\n\
* Compute a slug from the given `str`.\n\
*\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
exports.slug = function(str){\n\
return str\n\
.toLowerCase()\n\
.replace(/ +/g, '-')\n\
.replace(/[^-\\w]/g, '');\n\
};\n\
\n\
/**\n\
* Strip the function definition from `str`,\n\
* and re-indent for pre whitespace.\n\
*/\n\
\n\
exports.clean = function(str) {\n\
str = str\n\
.replace(/\\r\\n\
?|[\\n\
\\u2028\\u2029]/g, \"\\n\
\").replace(/^\\uFEFF/, '')\n\
.replace(/^function *\\(.*\\) *{/, '')\n\
.replace(/\\s+\\}$/, '');\n\
\n\
var spaces = str.match(/^\\n\
?( *)/)[1].length\n\
, tabs = str.match(/^\\n\
?(\\t*)/)[1].length\n\
, re = new RegExp('^\\n\
?' + (tabs ? '\\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm');\n\
\n\
str = str.replace(re, '');\n\
\n\
return exports.trim(str);\n\
};\n\
\n\
/**\n\
* Escape regular expression characters in `str`.\n\
*\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
exports.escapeRegexp = function(str){\n\
return str.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n\
};\n\
\n\
/**\n\
* Trim the given `str`.\n\
*\n\
* @param {String} str\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
exports.trim = function(str){\n\
return str.replace(/^\\s+|\\s+$/g, '');\n\
};\n\
\n\
/**\n\
* Parse the given `qs`.\n\
*\n\
* @param {String} qs\n\
* @return {Object}\n\
* @api private\n\
*/\n\
\n\
exports.parseQuery = function(qs){\n\
return exports.reduce(qs.replace('?', '').split('&'), function(obj, pair){\n\
var i = pair.indexOf('=')\n\
, key = pair.slice(0, i)\n\
, val = pair.slice(++i);\n\
\n\
obj[key] = decodeURIComponent(val);\n\
return obj;\n\
}, {});\n\
};\n\
\n\
/**\n\
* Highlight the given string of `js`.\n\
*\n\
* @param {String} js\n\
* @return {String}\n\
* @api private\n\
*/\n\
\n\
function highlight(js) {\n\
return js\n\
.replace(/</g, '&lt;')\n\
.replace(/>/g, '&gt;')\n\
.replace(/\\/\\/(.*)/gm, '<span class=\"comment\">//$1</span>')\n\
.replace(/('.*?')/gm, '<span class=\"string\">$1</span>')\n\
.replace(/(\\d+\\.\\d+)/gm, '<span class=\"number\">$1</span>')\n\
.replace(/(\\d+)/gm, '<span class=\"number\">$1</span>')\n\
.replace(/\\bnew *(\\w+)/gm, '<span class=\"keyword\">new</span> <span class=\"init\">$1</span>')\n\
.replace(/\\b(function|new|throw|return|var|if|else)\\b/gm, '<span class=\"keyword\">$1</span>')\n\
}\n\
\n\
/**\n\
* Highlight the contents of tag `name`.\n\
*\n\
* @param {String} name\n\
* @api private\n\
*/\n\
\n\
exports.highlightTags = function(name) {\n\
var code = document.getElementsByTagName(name);\n\
for (var i = 0, len = code.length; i < len; ++i) {\n\
code[i].innerHTML = highlight(code[i].innerHTML);\n\
}\n\
};\n\
\n\
}); // module: utils.js\n\
// The global object is \"self\" in Web Workers.\n\
global = (function() { return this; })();\n\
\n\
/**\n\
* Save timer references to avoid Sinon interfering (see GH-237).\n\
*/\n\
\n\
var Date = global.Date;\n\
var setTimeout = global.setTimeout;\n\
var setInterval = global.setInterval;\n\
var clearTimeout = global.clearTimeout;\n\
var clearInterval = global.clearInterval;\n\
\n\
/**\n\
* Node shims.\n\
*\n\
* These are meant only to allow\n\
* mocha.js to run untouched, not\n\
* to allow running node code in\n\
* the browser.\n\
*/\n\
\n\
var process = {};\n\
process.exit = function(status){};\n\
process.stdout = {};\n\
\n\
var uncaughtExceptionHandlers = [];\n\
\n\
/**\n\
* Remove uncaughtException listener.\n\
*/\n\
\n\
process.removeListener = function(e, fn){\n\
if ('uncaughtException' == e) {\n\
global.onerror = function() {};\n\
var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn);\n\
if (i != -1) { uncaughtExceptionHandlers.splice(i, 1); }\n\
}\n\
};\n\
\n\
/**\n\
* Implements uncaughtException listener.\n\
*/\n\
\n\
process.on = function(e, fn){\n\
if ('uncaughtException' == e) {\n\
global.onerror = function(err, url, line){\n\
fn(new Error(err + ' (' + url + ':' + line + ')'));\n\
return true;\n\
};\n\
uncaughtExceptionHandlers.push(fn);\n\
}\n\
};\n\
\n\
/**\n\
* Expose mocha.\n\
*/\n\
\n\
var Mocha = global.Mocha = require(\"mocha\"),\n\
mocha = global.mocha = new Mocha({ reporter: 'html' });\n\
\n\
// The BDD UI is registered by default, but no UI will be functional in the\n\
// browser without an explicit call to the overridden `mocha.ui` (see below).\n\
// Ensure that this default UI does not expose its methods to the global scope.\n\
mocha.suite.removeAllListeners('pre-require');\n\
\n\
var immediateQueue = []\n\
, immediateTimeout;\n\
\n\
function timeslice() {\n\
var immediateStart = new Date().getTime();\n\
while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {\n\
immediateQueue.shift()();\n\
}\n\
if (immediateQueue.length) {\n\
immediateTimeout = setTimeout(timeslice, 0);\n\
} else {\n\
immediateTimeout = null;\n\
}\n\
}\n\
\n\
/**\n\
* High-performance override of Runner.immediately.\n\
*/\n\
\n\
Mocha.Runner.immediately = function(callback) {\n\
immediateQueue.push(callback);\n\
if (!immediateTimeout) {\n\
immediateTimeout = setTimeout(timeslice, 0);\n\
}\n\
};\n\
\n\
/**\n\
* Function to allow assertion libraries to throw errors directly into mocha.\n\
* This is useful when running tests in a browser because window.onerror will\n\
* only receive the 'message' attribute of the Error.\n\
*/\n\
mocha.throwError = function(err) {\n\
Mocha.utils.forEach(uncaughtExceptionHandlers, function (fn) {\n\
fn(err);\n\
});\n\
throw err;\n\
};\n\
\n\
/**\n\
* Override ui to ensure that the ui functions are initialized.\n\
* Normally this would happen in Mocha.prototype.loadFiles.\n\
*/\n\
\n\
mocha.ui = function(ui){\n\
Mocha.prototype.ui.call(this, ui);\n\
this.suite.emit('pre-require', global, null, this);\n\
return this;\n\
};\n\
\n\
/**\n\
* Setup mocha with the given setting options.\n\
*/\n\
\n\
mocha.setup = function(opts){\n\
if ('string' == typeof opts) opts = { ui: opts };\n\
for (var opt in opts) this[opt](opts[opt]);\n\
return this;\n\
};\n\
\n\
/**\n\
* Run mocha, returning the Runner.\n\
*/\n\
\n\
mocha.run = function(fn){\n\
var options = mocha.options;\n\
mocha.globals('location');\n\
\n\
var query = Mocha.utils.parseQuery(global.location.search || '');\n\
if (query.grep) mocha.grep(query.grep);\n\
if (query.invert) mocha.invert();\n\
\n\
return Mocha.prototype.run.call(mocha, function(){\n\
// The DOM Document is not available in Web Workers.\n\
if (global.document) {\n\
Mocha.utils.highlightTags('code');\n\
}\n\
if (fn) fn();\n\
});\n\
};\n\
\n\
/**\n\
* Expose the process shim.\n\
*/\n\
\n\
Mocha.process = process;\n\
})();\n\
//# sourceURL=components/visionmedia/mocha/1.18.2/mocha.js"
));
require.modules["visionmedia-mocha"] = require.modules["visionmedia~mocha@1.18.2"];
require.modules["visionmedia~mocha"] = require.modules["visionmedia~mocha@1.18.2"];
require.modules["mocha"] = require.modules["visionmedia~mocha@1.18.2"];
require.register("visionmedia~mocha-matrix@0.0.1", Function("exports, module",
"\n\
//# sourceURL=components/visionmedia/mocha-matrix/0.0.1/index.js"
));
require.modules["visionmedia-mocha-matrix"] = require.modules["visionmedia~mocha-matrix@0.0.1"];
require.modules["visionmedia~mocha-matrix"] = require.modules["visionmedia~mocha-matrix@0.0.1"];
require.modules["mocha-matrix"] = require.modules["visionmedia~mocha-matrix@0.0.1"];
require.register("k", Function("exports, module",
"\n\
/**\n\
* dependencies.\n\
*/\n\
\n\
var event = require(\"component~event@0.1.3\")\n\
, proto = require(\"k/lib/proto.js\")\n\
, bind = require(\"component~bind@0.0.1\");\n\
\n\
/**\n\
* Create a new dispatcher with `el`.\n\
*\n\
* example:\n\
*\n\
* var k = require(\"k\")(window);\n\
* k('shift + tab', function(){});\n\
*\n\
* @param {Element} el\n\
* @return {Function}\n\
* @api public\n\
*/\n\
\n\
module.exports = function(el){\n\
function k(e, fn){ k.handle(e, fn) };\n\
k._handle = bind(k, proto.handle);\n\
k._clear = bind(k, proto.clear);\n\
event.bind(el, 'keydown', k._handle, false);\n\
event.bind(el, 'keyup', k._handle, false);\n\
event.bind(el, 'keyup', k._clear, false);\n\
event.bind(el, 'focus', k._clear, false);\n\
for (var p in proto) k[p] = proto[p];\n\
k.listeners = [];\n\
k.el = el;\n\
return k;\n\
};\n\
\n\
//# sourceURL=lib/index.js"
));
require.register("k/lib/proto.js", Function("exports, module",
"\n\
/**\n\
* dependencies\n\
*/\n\
\n\
var sequence = require(\"yields~k-sequence@0.1.0\")\n\
, keycode = require(\"yields~keycode@1.0.0\")\n\
, event = require(\"component~event@0.1.3\")\n\
, os = require(\"component~os@0.0.1\");\n\
\n\
/**\n\
* modifiers.\n\
*/\n\
\n\
var modifiers = {\n\
224: 'command',\n\
91: 'command',\n\
93: 'command',\n\
16: 'shift',\n\
17: 'ctrl',\n\
18: 'alt'\n\
};\n\
\n\
/**\n\
* Super key.\n\
*/\n\
\n\
exports.super = 'mac' == os\n\
? 'command'\n\
: 'ctrl';\n\
\n\
/**\n\
* Handle the given `KeyboardEvent` or bind\n\
* a new `keys` handler.\n\
*\n\
* @param {String|KeyboardEvent} e\n\
* @param {Function} fn\n\
* @api private\n\
*/\n\
\n\
exports.handle = function(e, fn){\n\
var ignore = this.ignore;\n\
var event = e.type;\n\
var code = e.which;\n\
\n\
// bind\n\
if (fn) return this.bind(e, fn);\n\
\n\
// modifiers\n\
var mod = modifiers[code];\n\
if ('keydown' == event && mod) {\n\
this.super = exports.super == mod;\n\
this[mod] = true;\n\
this.modifiers = true;\n\
return;\n\
}\n\
\n\
// ignore\n\
if (ignore && ignore(e)) return;\n\
\n\
// listeners\n\
var all = this.listeners;\n\
\n\
// match\n\
for (var i = 0; i < all.length; ++i) {\n\
var invoke = true;\n\
var obj = all[i];\n\
var seq = obj.seq;\n\
var mods = obj.mods;\n\
var fn = seq || obj.fn;\n\
\n\
if (!seq && code != obj.code) continue;\n\
if (event != obj.event) continue;\n\
\n\
for (var j = 0; j < mods.length; ++j) {\n\
if (!this[mods[j]]) {\n\
invoke = null;\n\
break;\n\
}\n\
}\n\
\n\
invoke && fn(e);\n\
}\n\
};\n\
\n\
/**\n\
* Destroy this `k` dispatcher instance.\n\
*\n\
* @api public\n\
*/\n\
\n\
exports.destroy = function(){\n\
event.unbind(this.el, 'keydown', this._handle);\n\
event.unbind(this.el, 'keyup', this._handle);\n\
event.unbind(this.el, 'keyup', this._clear);\n\
event.unbind(this.el, 'focus', this._clear);\n\
this.listeners = [];\n\
};\n\
\n\
/**\n\
* Unbind the given `keys` with optional `fn`.\n\
*\n\
* example:\n\
*\n\
* k.unbind('enter, tab', myListener); // unbind `myListener` from `enter, tab` keys\n\
* k.unbind('enter, tab'); // unbind all `enter, tab` listeners\n\
* k.unbind(); // unbind all listeners\n\
*\n\
* @param {String} keys\n\
* @param {Function} fn\n\
* @return {k}\n\
* @api public\n\
*/\n\
\n\
exports.unbind = function(keys, fn){\n\
var fns = this.listeners\n\
, len = fns.length\n\
, all;\n\
\n\
// unbind all\n\
if (0 == arguments.length) {\n\
this.listeners = [];\n\
return this;\n\
}\n\
\n\
// parse\n\
all = parseKeys(keys);\n\
\n\
// unbind\n\
for (var i = 0; i < all.length; ++i) {\n\
for (var j = 0, obj; j < len; ++j) {\n\
obj = fns[j];\n\
if (!obj) continue;\n\
if (fn && obj.fn != fn) continue;\n\
if (obj.key != all[i].key) continue;\n\
if (!matches(obj, all[i])) continue;\n\
fns.splice(j--, 1);\n\
}\n\
}\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Bind the given `keys` to `fn` with optional `event`\n\
*\n\
* example:\n\
*\n\
* k.bind('shift + tab, ctrl + a', function(e){});\n\
*\n\
* @param {String} event\n\
* @param {String} keys\n\
* @param {Function} fn\n\
* @return {k}\n\
* @api public\n\
*/\n\
\n\
exports.bind = function(event, keys, fn){\n\
var fns = this.listeners\n\
, len\n\
, all;\n\
\n\
if (2 == arguments.length) {\n\
fn = keys;\n\
keys = event;\n\
event = 'keydown';\n\
}\n\
\n\
all = parseKeys(keys);\n\
len = all.length;\n\
\n\
for (var i = 0; i < len; ++i) {\n\
var obj = all[i];\n\
obj.seq = obj.seq && sequence(obj.key, fn);\n\
obj.event = event;\n\
obj.fn = fn;\n\
fns.push(obj);\n\
}\n\
\n\
return this;\n\
};\n\
\n\
/**\n\
* Bind keyup with `keys` and `fn`.\n\
*\n\
* @param {String} keys\n\
* @param {Function} fn\n\
* @return {k}\n\
* @api public\n\
*/\n\
\n\
exports.up = function(keys, fn){\n\
return this.bind('keyup', keys, fn);\n\
};\n\
\n\
/**\n\
* Bind keydown with `keys` and `fn`.\n\
*\n\
* @param {String} keys\n\
* @param {Function} fn\n\
* @return {k}\n\
* @api public\n\
*/\n\
\n\
exports.down = function(keys, fn){\n\
return this.bind('keydown', keys, fn);\n\
};\n\
\n\
/**\n\
* Clear all modifiers on `keyup`.\n\
*\n\
* @api private\n\
*/\n\
\n\
exports.clear = function(e){\n\
var code = e.keyCode || e.which;\n\
if (!(code in modifiers)) return;\n\
this[modifiers[code]] = null;\n\
this.modifiers = this.command\n\
|| this.shift\n\
|| this.ctrl\n\
|| this.alt;\n\
};\n\
\n\
/**\n\
* Ignore all input elements by default.\n\
*\n\
* @param {Event} e\n\
* @return {Boolean}\n\
* @api private\n\
*/\n\
\n\
exports.ignore = function(e){\n\
var el = e.target || e.srcElement;\n\
var name = el.tagName.toLowerCase();\n\
return 'textarea' == name\n\
|| 'select' == name\n\
|| 'input' == name;\n\
};\n\
\n\
/**\n\
* Parse the given `keys`.\n\
*\n\
* @param {String} keys\n\
* @return {Array}\n\
* @api private\n\
*/\n\
\n\
function parseKeys(keys){\n\
keys = keys.replace('super', exports.super);\n\
\n\
var all = ',' != keys\n\
? keys.split(/ *, */)\n\
: [','];\n\
\n\
var ret = [];\n\
for (var i = 0; i < all.length; ++i) {\n\
if ('' == all[i]) continue;\n\
var mods = all[i].split(/ *\\+ */);\n\
var key = mods.pop() || ',';\n\
\n\
ret.push({\n\
seq: !!~ key.indexOf(' '),\n\
code: keycode(key),\n\
mods: mods,\n\
key: key\n\
});\n\
}\n\
\n\
return ret;\n\
}\n\
\n\
/**\n\
* Check if the given `a` matches `b`.\n\
*\n\
* @param {Object} a\n\
* @param {Object} b\n\
* @return {Boolean}\n\
* @api private\n\
*/\n\
\n\
function matches(a, b){\n\
return 0 == b.mods.length || eql(a, b);\n\
}\n\
\n\
/**\n\
* Shallow eql util.\n\
*\n\
* TODO: move to yields/eql\n\
*\n\
* @param {Array} a\n\
* @param {Array} b\n\
* @return {Boolean}\n\
* @api private\n\
*/\n\
\n\
function eql(a, b){\n\
a = a.mods.sort().toString();\n\
b = b.mods.sort().toString();\n\
return a == b;\n\
}\n\
\n\
//# sourceURL=lib/proto.js"
));
require.modules["k"] = require.modules["k"];
require("k")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment