;(function(window, undefined) { 'use strict'; /** Object shortcuts */ var phantom = window.phantom, process = window.process, system = window.system; /** The file path of the Lo-Dash file to test */ var filePath = (function() { var min = 0, args = window.arguments, result = []; if (phantom) { result = phantom.args; } else if (system) { min = 1; result = system.args; } else if (process) { min = 2; result = process.argv; } else if (args) { result = args; } var last = result[result.length - 1]; result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js'; try { return typeof define == 'undefined' && require('fs').realpathSync(result); } catch(e) { return result; } }()); /** The `ui` object */ var ui = window.ui || (window.ui = { 'buildPath': filePath, 'loaderPath': '', 'urlParams': {} }); /** Used to indicate testing a modularized build */ var isModularize = /\b(?:lodash-(?:amd|node)|modularize)\b/.test([ui.buildPath, ui.urlParams.build]); /*--------------------------------------------------------------------------*/ // exit early if running tests in phantomjs page if (phantom && isModularize) { var page = require('webpage').create(); page.open(filePath, function(status) { if (status !== 'success') { phantom.exit(1); } }); page.onCallback = function(details) { phantom.exit(details.failed ? 1 : 0); }; page.onConsoleMessage = function(message) { console.log(message); }; page.onInitialized = function() { page.evaluate(function() { document.addEventListener('DOMContentLoaded', function() { var xhr = new XMLHttpRequest; xhr.open('GET', '../vendor/qunit-clib/qunit-clib.js'); xhr.onload = function() { var script = document.createElement('script'); script.text = xhr.responseText; document.head.appendChild(script); QUnit.done(callPhantom); }; xhr.send(null); }, false); }); }; return; } /*--------------------------------------------------------------------------*/ /** Method and object shortcuts */ var document = !phantom && window.document, amd = window.define && define.amd, body = document && document.body, create = Object.create, freeze = Object.freeze, push = Array.prototype.push, slice = Array.prototype.slice, toString = Object.prototype.toString, Worker = !phantom && window.Worker; /** Use a single "load" function */ var load = !amd && typeof require == 'function' ? require : window.load; /** The basename of the Lo-Dash file to test */ var basename = /[\w.-]+$/.exec(filePath)[0]; /** The unit testing framework */ var QUnit = (function() { var noop = Function.prototype; return window.QUnit || ( window.addEventListener || (window.addEventListener = noop), window.setTimeout || (window.setTimeout = noop), window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit, (load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(window), addEventListener === noop && delete window.addEventListener, window.QUnit ); }()); /** The `lodash` function to test */ var _ = window._ || (window._ = ( _ = load(filePath) || window._, _ = _._ || _, (_.runInContext ? _.runInContext(window) : _) )); /** Used to pass falsey values to methods */ var falsey = [, '', 0, false, NaN, null, undefined]; /** Used as the size when optimizations are enabled for large arrays */ var largeArraySize = 75; /** Used to set property descriptors */ var defineProperty = (function() { try { var o = {}, func = Object.defineProperty, result = func(o, o, o) && func; } catch(e) { } return result; }()); /** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */ var shadowedProps = [ 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf' ]; /** Used to check problem JScript properties too */ var shadowedObject = _.invert(shadowedProps); /*--------------------------------------------------------------------------*/ /** * Skips a given number of tests with a passing result. * * @private * @param {number} [count=1] The number of tests to skip. */ function skipTest(count) { count || (count = 1); while (count--) { ok(true, 'test skipped'); } } /*--------------------------------------------------------------------------*/ // add object from iframe (function() { if (!document) { return; } 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("