|
1 | 1 | ;(function(root, undefined) {
|
2 | 2 | 'use strict';
|
3 | 3 |
|
4 |
| - /** Object shortcuts */ |
5 |
| - var amd = root.define && define.amd, |
6 |
| - phantom = root.phantom, |
| 4 | + /** Method and object shortcuts */ |
| 5 | + var phantom = root.phantom, |
| 6 | + amd = root.define && define.amd, |
| 7 | + document = !phantom && root.document, |
| 8 | + body = document && document.body, |
| 9 | + create = Object.create, |
| 10 | + freeze = Object.freeze, |
| 11 | + params = root.arguments, |
7 | 12 | process = root.process,
|
8 |
| - system = root.system; |
| 13 | + push = Array.prototype.push, |
| 14 | + slice = Array.<
10000
span class=pl-c1>prototype.slice, |
| 15 | + system = root.system, |
| 16 | + toString = Object.prototype.toString, |
| 17 | + Worker = document && root.Worker; |
9 | 18 |
|
10 | 19 | /** The file path of the Lo-Dash file to test */
|
11 | 20 | var filePath = (function() {
|
12 | 21 | var min = 0,
|
13 |
| - args = root.arguments, |
14 | 22 | result = [];
|
15 | 23 |
|
16 | 24 | if (phantom) {
|
17 |
| - result = phantom.args; |
| 25 | + result = params = phantom.args; |
18 | 26 | } else if (system) {
|
19 | 27 | min = 1;
|
20 |
| - result = system.args; |
| 28 | + result = params = system.args; |
21 | 29 | } else if (process) {
|
22 | 30 | min = 2;
|
23 |
| - result = process.argv; |
24 |
| - } else if (args) { |
25 |
| - result = args; |
| 31 | + result = params = process.argv; |
| 32 | + } else if (params) { |
| 33 | + result = params; |
26 | 34 | }
|
27 | 35 | var last = result[result.length - 1];
|
28 | 36 | result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js';
|
|
36 | 44 | return result;
|
37 | 45 | }());
|
38 | 46 |
|
39 |
| - /** The basename of the Lo-Dash file to test */ |
40 |
| - var basename = /[\w.-]+$/.exec(filePath)[0]; |
41 |
| - |
42 | 47 | /** The `ui` object */
|
43 | 48 | var ui = root.ui || (root.ui = {
|
44 | 49 | 'buildPath': filePath,
|
45 | 50 | 'loaderPath': '',
|
46 | 51 | 'urlParams': {}
|
47 | 52 | });
|
48 | 53 |
|
| 54 | + /** The basename of the Lo-Dash file to test */ |
| 55 | + var basename = /[\w.-]+$/<
10000
/span>.exec(filePath)[0]; |
| 56 | + |
49 | 57 | /** Used to indicate testing a modularized build */
|
50 | 58 | var isModularize = ui.isModularize || /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|node)|modularize|npm)\b/.test([ui.buildPath, ui.urlParams.build, basename]);
|
51 | 59 |
|
| 60 | + /** Detect if testing `npm` modules */ |
| 61 | + var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); |
| 62 | + |
| 63 | + /** Detects if running in a PhantomJS web page */ |
| 64 | + var isPhantomPage = typeof callPhantom == 'function'; |
| 65 | + |
| 66 | + /** Detect if running in Rhino */ |
| 67 | + var isRhino = root.java && typeof global == 'function' && global().Array === root.Array; |
| 68 | + |
| 69 | + /** Use a single "load" function */ |
| 70 | + var load = !amd && typeof require == 'function' ? require : root.load; |
| 71 | + |
| 72 | + /** The unit testing framework */ |
| 73 | + var QUnit = (function() { |
| 74 | + var noop = Function.prototype; |
| 75 | + return root.QUnit || ( |
| 76 | + root.addEventListener || (root.addEventListener = noop), |
| 77 | + root.setTimeout || (root.setTimeout = noop), |
| 78 | + root.QUnit = load('../vendor/qunit/qunit/qunit.js') || root.QUnit, |
| 79 | + (load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(root), |
| 80 | + addEventListener === noop && delete root.addEventListener, |
| 81 | + root.QUnit |
| 82 | + ); |
| 83 | + }()); |
| 84 | + |
52 | 85 | /*--------------------------------------------------------------------------*/
|
53 | 86 |
|
| 87 | + // log params passed to `test.js` |
| 88 | + if (params) { |
| 89 | + console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params))); |
| 90 | + } |
54 | 91 | // exit early if going to run tests in a PhantomJS web page
|
55 | 92 | if (phantom && isModularize) {
|
56 | 93 | var page = require('webpage').create();
|
|
91 | 128 |
|
92 | 129 | /*--------------------------------------------------------------------------*/
|
93 | 130 |
|
94 |
| - /** Method and object shortcuts */ |
95 |
| - var document = !phantom && root.document, |
96 |
| - body = document && document.body, |
97 |
| - create = Object.create, |
98 |
| - freeze = Object.freeze, |
99 |
| - push = Array.prototype.push, |
100 |
| - slice = Array.prototype.slice, |
101 |
| - toString = Object.prototype.toString, |
102 |
| - Worker = document && root.Worker; |
103 |
| - |
104 |
| - /** Detect if testing `npm` modules */ |
105 |
| - var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); |
106 |
| - |
107 |
| - /** Detects if running in a PhantomJS web page */ |
108 |
| - var isPhantomPage = typeof callPhantom == 'function'; |
109 |
| - |
110 |
| - /** Detect if running in Rhino */ |
111 |
| - var isRhino = root.java && typeof global == 'function' && global().Array === root.Array; |
112 |
| - |
113 |
| - /** Use a single "load" function */ |
114 |
| - var load = !amd && typeof require == 'function' ? require : root.load; |
115 |
| - |
116 |
| - /** The unit testing framework */ |
117 |
| - var QUnit = (function() { |
118 |
| - var noop = Function.prototype; |
119 |
| - return root.QUnit || ( |
120 |
| - root.addEventListener || (root.addEventListener = noop), |
121 |
| - root.setTimeout || (root.setTimeout = noop), |
122 |
| - root.QUnit = load('../vendor/qunit/qunit/qunit.js') || root.QUnit, |
123 |
| - (load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(root), |
124 |
| - addEventListener === noop && delete root.addEventListener, |
125 |
| - root.QUnit |
126 |
| - ); |
127 |
| - }()); |
128 |
| - |
129 | 131 | /** The `lodash` function to test */
|
130 | 132 | var _ = root._ || (root._ = (
|
131 | 133 | _ = load(filePath) || root._,
|
|
163 | 165 | /** Used to check problem JScript properties too */
|
164 | 166 | var shadowedObject = _.invert(shadowedProps);
|
165 | 167 |
|
166 |
| - /*--------------------------------------------------------------------------*/ |
167 |
| - |
168 | 168 | /**
|
169 | 169 | * Skips a given number of tests with a passing result.
|
170 | 170 | *
|
|
0 commit comments