;(function() { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150; /** Used as the size to cover large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991, MAX_INTEGER = 1.7976931348623157e+308; /** Used as references for the maximum length and index of an array. */ var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; /** `Object#toString` result references. */ var funcTag = '[object Function]', numberTag = '[object Number]', objectTag = '[object Object]'; /** Used as a reference to the global object. */ var root = (typeof global == 'object' && global) || this; /** Used to store lodash to test for bad extensions/shims. */ var lodashBizarro = root.lodashBizarro; /** Used for native method references. */ var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype, numberProto = Number.prototype, stringProto = String.prototype; /** Method and object shortcuts. */ var phantom = root.phantom, process = root.process, amd = root.define && define.amd, argv = process && process.argv, defineProperty = Object.defineProperty, document = !phantom && root.document, body = root.document && root.document.body, create = Object.create, fnToString = funcProto.toString, freeze = Object.freeze, getSymbols = Object.getOwnPropertySymbols, identity = function(value) { return value; }, JSON = root.JSON, noop = function() {}, objToString = objectProto.toString, params = argv, push = arrayProto.push, realm = {}, slice = arrayProto.slice; var ArrayBuffer = root.ArrayBuffer, Buffer = root.Buffer, Promise = root.Promise, Map = root.Map, Set = root.Set, Symbol = root.Symbol, Uint8Array = root.Uint8Array, WeakMap = root.WeakMap, WeakSet = root.WeakSet; var arrayBuffer = ArrayBuffer ? new ArrayBuffer(2) : undefined, map = Map ? new Map : undefined, promise = Promise ? Promise.resolve(1) : undefined, set = Set ? new Set : undefined, symbol = Symbol ? Symbol('a') : undefined, weakMap = WeakMap ? new WeakMap : undefined, weakSet = WeakSet ? new WeakSet : undefined; /** Math helpers. */ var add = function(x, y) { return x + y; }, doubled = function(n) { return n * 2; }, isEven = function(n) { return n % 2 == 0; }, square = function(n) { return n * n; }; /** Stub functions. */ var stubA = function() { return 'a'; }, stubB = function() { return 'b'; }, stubC = function() { return 'c'; }; var stubTrue = function() { return true; }, stubFalse = function() { return false; }; var stubNaN = function() { return NaN; }, stubNull = function() { return null; }; var stubZero = function() { return 0; }, stubOne = function() { return 1; }, stubTwo = function() { return 2; }, stubThree = function() { return 3; }, stubFour = function() { return 4; }; var stubArray = function() { return []; }, stubObject = function() { return {}; }, stubString = function() { return ''; }; /** List of latin-1 supplementary letters to basic latin letters. */ var burredLetters = [ '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf', '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf', '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' ]; /** List of combining diacritical marks. */ var comboMarks = [ '\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307', '\u0308', '\u0309', '\u030a', '\u030b', '\u030c', '\u030d', '\u030e', '\u030f', '\u0310', '\u0311', '\u0312', '\u0313', '\u0314', '\u0315', '\u0316', '\u0317', '\u0318', '\u0319', '\u031a', '\u031b', '\u031c', '\u031d', '\u031e', '\u031f', '\u0320', '\u0321', '\u0322', '\u0323', '\u0324', '\u0325', '\u0326', '\u0327', '\u0328', '\u0329', '\u032a', '\u032b', '\u032c', '\u032d', '\u032e', '\u032f', '\u0330', '\u0331', '\u0332', '\u0333', '\u0334', '\u0335', '\u0336', '\u0337', '\u0338', '\u0339', '\u033a', '\u033b', '\u033c', '\u033d', '\u033e', '\u033f', '\u0340', '\u0341', '\u0342', '\u0343', '\u0344', '\u0345', '\u0346', '\u0347', '\u0348', '\u0349', '\u034a', '\u034b', '\u034c', '\u034d', '\u034e', '\u034f', '\u0350', '\u0351', '\u0352', '\u0353', '\u0354', '\u0355', '\u0356', '\u0357', '\u0358', '\u0359', '\u035a', '\u035b', '\u035c', '\u035d', '\u035e', '\u035f', '\u0360', '\u0361', '\u0362', '\u0363', '\u0364', '\u0365', '\u0366', '\u0367', '\u0368', '\u0369', '\u036a', '\u036b', '\u036c', '\u036d', '\u036e', '\u036f', '\ufe20', '\ufe21', '\ufe22', '\ufe23' ]; /** List of `burredLetters` translated to basic latin letters. */ var deburredLetters = [ 'A', 'A', 'A', 'A', 'A', 'A', 'Ae', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y' ]; /** Used to provide falsey values to methods. */ var falsey = [, null, undefined, false, 0, NaN, '']; /** Used to specify the emoji style glyph variant of characters. */ var emojiVar = '\ufe0f'; /** Used to provide empty values to methods. */ var empties = [[], {}].concat(falsey.slice(1)); /** Used to test error objects. */ var errors = [ new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError ]; /** List of fitzpatrick modifiers. */ var fitzModifiers = [ '\ud83c\udffb', '\ud83c\udffc', '\ud83c\udffd', '\ud83c\udffe', '\ud83c\udfff' ]; /** Used to provide primitive values to methods. */ var primitives = [null, undefined, false, true, 1, NaN, 'a']; /** Used to check whether methods support typed arrays. */ var typedArrays = [ 'Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array' ]; /** Used to check whether methods support array views. */ var arrayViews = typedArrays.concat('DataView'); /** The file path of the lodash file to test. */ var filePath = (function() { var min = 2, result = params || []; if (phantom) { min = 0; result = params = phantom.args || require('system').args; } var last = result[result.length - 1]; result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js'; if (!amd) { try { result = require('fs').realpathSync(result); } catch (e) {} try { result = require.resolve(result); } catch (e) {} } return result; }()); /** The `ui` object. */ var ui = root.ui || (root.ui = { 'buildPath': filePath, 'loaderPath': '', 'isModularize': /\b(?:amd|commonjs|es|node|npm|(index|main)\.js)\b/.test(filePath), 'isStrict': /\bes\b/.test(filePath) || 'default' in require(filePath), 'urlParams': {} }); /** The basename of the lodash file to test. */ var basename = /[\w.-]+$/.exec(filePath)[0]; /** Used to indicate testing a modularized build. */ var isModularize = ui.isModularize; /** Detect if testing `npm` modules. */ var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); /** Detect if running in PhantomJS. */ var isPhantom = phantom || (typeof callPhantom == 'function'); /** Detect if lodash is in strict mode. */ var isStrict = ui.isStrict; /*--------------------------------------------------------------------------*/ // Leak to avoid sporadic `noglobals` fails on Edge in Sauce Labs. root.msWDfn = undefined; // Assign `setTimeout` to itself to avoid being flagged as a leak. setProperty(root, 'setTimeout', setTimeout); // Exit early if going to run tests in a PhantomJS web page. if (phantom && isModularize) { var page = require('webpage').create(); page.onCallback = function(details) { var coverage = details.coverage; if (coverage) { var fs = require('fs'), cwd = fs.workingDirectory, sep = fs.separator; fs.write([cwd, 'coverage', 'coverage.json'].join(sep), JSON.stringify(coverage)); } phantom.exit(details.failed ? 1 : 0); }; page.onConsoleMessage = function(message) { console.log(message); }; page.onInitialized = function() { page.evaluate(function() { document.addEventListener('DOMContentLoaded', function() { QUnit.done(function(details) { details.coverage = window.__coverage__; callPhantom(details); }); }); }); }; page.open(filePath, function(status) { if (status != 'success') { console.log('PhantomJS failed to load page: ' + filePath); phantom.exit(1); } }); console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params))); return; } /*--------------------------------------------------------------------------*/ /** Used to test Web Workers. */ var Worker = !(ui.isForeign || ui.isSauceLabs || isModularize) && (document && document.origin != 'null') && root.Worker; /** Used to test host objects in IE. */ try { var xml = new ActiveXObject('Microsoft.XMLDOM'); } catch (e) {} /** Poison the free variable `root` in Node.js */ try { defineProperty(global.root, 'root', { 'configurable': false, 'enumerable': false, 'get': function() { throw new ReferenceError; } }); } catch (e) {} /** Load QUnit and extras. */ var QUnit = root.QUnit || require('qunit-extras'); /** Load stable Lodash. */ var lodashStable = root.lodashStable; if (!lodashStable) { try { lodashStable = interopRequire('../node_modules/lodash/lodash.js'); } catch (e) { console.log('Error: The stable lodash dev dependency should be at least a version behind master branch.'); return; } lodashStable = lodashStable.noConflict(); } /** The `lodash` function to test. */ var _ = root._ || (root._ = interopRequire(filePath)); /** Used to test pseudo private map caches. */ var mapCaches = (function() { var MapCache = _.memoize.Cache; var result = { 'Hash': new MapCache().__data__.hash.constructor, 'MapCache': MapCache }; _.isMatchWith({ 'a': 1 }, { 'a': 1 }, function() { var stack = lodashStable.last(arguments); result.ListCache = stack.__data__.constructor; result.Stack = stack.constructor; }); return result; }()); /** Used to detect instrumented istanbul code coverage runs. */ var coverage = root.__coverage__ || root[lodashStable.findKey(root, function(value, key) { return /^(?:\$\$cov_\d+\$\$)$/.test(key); })]; /** Used to test generator functions. */ var generator = lodashStable.attempt(function() { return Function('return function*(){}'); }); /** Used to restore the `_` reference. */ var oldDash = root._; /** * Used to check for problems removing whitespace. For a whitespace reference, * see [V8's unit test](https://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/whitespaces.js). */ var whitespace = lodashStable.filter([ // Basic whitespace characters. ' ', '\t', '\x0b', '\f', '\xa0', '\ufeff', // Line terminators. '\n', '\r', '\u2028', '\u2029', // Unicode category "Zs" space separators. '\u1680', '\u180e', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u202f', '\u205f', '\u3000' ], function(chr) { return /\s/.exec(chr); }) .join(''); /** * Creates a custom error object. * * @private * @constructor * @param {string} message The error message. */ function CustomError(message) { this.name = 'CustomError'; this.message = message; } CustomError.prototype = lodashStable.create(Error.prototype, { 'constructor': CustomError }); /** * Removes all own enumerable string keyed properties from a given object. * * @private * @param {Object} object The object to empty. */ function emptyObject(object) { lodashStable.forOwn(object, function(value, key, object) { delete object[key]; }); } /** * Extracts the unwrapped value from its wrapper. * * @private * @param {Object} wrapper The wrapper to unwrap. * @returns {*} Returns the unwrapped value. */ function getUnwrappedValue(wrapper) { var index = -1, actions = wrapper.__actions__, length = actions.length, result = wrapper.__wrapped__; while (++index < length) { var args = [result], action = actions[index]; push.apply(args, action.args); result = action.func.apply(action.thisArg, args); } return result; } /** * Loads the module of `id`. If the module has an `exports.default`, the * exported default value is returned as the resolved module. * * @private * @param {string} id The identifier of the module to resolve. * @returns {*} Returns the resolved module. */ function interopRequire(id) { var result = require(id); return 'default' in result ? result['default'] : result; } /** * Sets a non-enumerable property value on `object`. * * Note: This function is used to avoid a bug in older versions of V8 where * overwriting non-enumerable built-ins makes them enumerable. * See https://code.google.com/p/v8/issues/detail?id=1623 * * @private * @param {Object} object The object modify. * @param {string} key The name of the property to set. * @param {*} value The property value. */ function setProperty(object, key, value) { try { defineProperty(object, key, { 'configurable': true, 'enumerable': false, 'writable': true, 'value': value }); } catch (e) { object[key] = value; } return object; } /** * Skips a given number of tests with a passing result. * * @private * @param {Object} assert The QUnit assert object. * @param {number} [count=1] The number of tests to skip. */ function skipAssert(assert, count) { count || (count = 1); while (count--) { assert.ok(true, 'test skipped'); } } /*--------------------------------------------------------------------------*/ // Add bizarro values. (function() { if (document || (typeof require != 'function')) { return; } var nativeString = fnToString.call(toString), reToString = /toString/g; function createToString(funcName) { return lodashStable.constant(nativeString.replace(reToString, funcName)); } // Allow bypassing native checks. setProperty(funcProto, 'toString', function wrapper() { setProperty(funcProto, 'toString', fnToString); var result = lodashStable.has(this, 'toString') ? this.toString() : fnToString.call(this); setProperty(funcProto, 'toString', wrapper); return result; }); // Add prototype extensions. funcProto._method = noop; // Set bad shims. setProperty(Object, 'create', (function() { function object() {} return function(prototype) { if (lodashStable.isObject(prototype)) { object.prototype = prototype; var result = new object; object.prototype = undefined; } return result || {}; }; }())); setProperty(Object, 'getOwnPropertySymbols', undefined); var _propertyIsEnumerable = objectProto.propertyIsEnumerable; setProperty(objectProto, 'propertyIsEnumerable', function(key) { return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key); }); if (Buffer) { defineProperty(root, 'Buffer', { 'configurable': true, 'enumerable': true, 'get': function get() { var caller = get.caller, name = caller ? caller.name : ''; if (!(name == 'runInContext' || name.length == 1 || /\b_\.isBuffer\b/.test(caller))) { return Buffer; } } }); } if (Map) { setProperty(root, 'Map', (function() { var count = 0; return function() { if (count++) { return new Map; } setProperty(root, 'Map', Map); return {}; }; }())); setProperty(root.Map, 'toString', createToString('Map')); } setProperty(root, 'Promise', noop); setProperty(root, 'Set', noop); setProperty(root, 'Symbol', undefined); setProperty(root, 'WeakMap', noop); // Fake `WinRTError`. setProperty(root, 'WinRTError', Error); // Clear cache so lodash can be reloaded. emptyObject(require.cache); // Load lodash and expose it to the bad extensions/shims. lodashBizarro = interopRequire(filePath); root._ = oldDash; // Restore built-in methods. setProperty(Object, 'create', create); setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable); setProperty(root, 'Buffer', Buffer); if (getSymbols) { Object.getOwnPropertySymbols = getSymbols; } else { delete Object.getOwnPropertySymbols; } if (Map) { setProperty(root, 'Map', Map); } else { delete root.Map; } if (Promise) { setProperty(root, 'Promise', Promise); } else { delete root.Promise; } if (Set) { setProperty(root, 'Set', Set); } else { delete root.Set; } if (Symbol) { setProperty(root, 'Symbol', Symbol); } else { delete root.Symbol; } if (WeakMap) { setProperty(root, 'WeakMap', WeakMap); } else { delete root.WeakMap; } delete root.WinRTError; delete funcProto._method; }()); // Add other realm values from the `vm` module. lodashStable.attempt(function() { lodashStable.assign(realm, require('vm').runInNewContext([ '(function() {', ' var noop = function() {},', ' root = this;', '', ' var object = {', " 'ArrayBuffer': root.ArrayBuffer,", " 'arguments': (function() { return arguments; }(1, 2, 3)),", " 'array': [1],", " 'arrayBuffer': root.ArrayBuffer ? new root.ArrayBuffer : undefined,", " 'boolean': Object(false),", " 'date': new Date,", " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", " 'function': noop,", " 'map': root.Map ? new root.Map : undefined,", " 'nan': NaN,", " 'null': null,", " 'number': Object(0),", " 'object': { 'a': 1 },", " 'promise': root.Promise ? Promise.resolve(1) : undefined,", " 'regexp': /x/,", " 'set': root.Set ? new root.Set : undefined,", " 'string': Object('a'),", " 'symbol': root.Symbol ? root.Symbol() : undefined,", " 'undefined': undefined,", " 'weakMap': root.WeakMap ? new root.WeakMap : undefined,", " 'weakSet': root.WeakSet ? new root.WeakSet : undefined", ' };', '', " ['" + arrayViews.join("', '") + "'].forEach(function(type) {", ' var Ctor = root[type]', ' object[type] = Ctor;', ' object[type.toLowerCase()] = Ctor ? new Ctor(new ArrayBuffer(24)) : undefined;', ' });', '', ' return object;', '}())' ].join('\n'))); }); // Add other realm values from an iframe. lodashStable.attempt(function() { _._realm = realm; var iframe = document.createElement('iframe'); iframe.frameBorder = iframe.height = iframe.width = 0; body.appendChild(iframe); var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; idoc.write([ '