1<!doctype html>
2<html lang="en">
3  <head>
4    <meta charset="utf-8">
5    <title>Underscore Test Suite</title>
6    <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
7  </head>
8  <body>
9    <div id="qunit"></div>
10    <script>
11      // Avoid reporting tests to Sauce Labs when script errors occur.
12      if (location.port == '9001') {
13        window.onerror = function(message) {
14          if (window.QUnit) {
15            QUnit.config.done.length = 0;
16          }
17          global_test_results = { 'message': message };
18        };
19      }
20    </script>
21    <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
22    <script src="../node_modules/qunit-extras/qunit-extras.js"></script>
23    <script src="../node_modules/jquery/dist/jquery.js"></script>
24    <script src="../node_modules/platform/platform.js"></script>
25    <script src="./asset/test-ui.js"></script>
26    <script src="../lodash.js"></script>
27    <script>
28      QUnit.config.asyncRetries = 10;
29      QUnit.config.hidepassed = true;
30      QUnit.config.excused = {
31        'Arrays': {
32          'chunk': [
33            'defaults to empty array (chunk size 0)'
34          ],
35          'difference': [
36            'can perform an OO-style difference'
37          ],
38          'drop': [
39            'is an alias for rest'
40          ],
41          'first': [
42            'returns an empty array when n <= 0 (0 case)',
43            'returns an empty array when n <= 0 (negative case)',
44            'can fetch the first n elements',
45            'returns the whole array if n > length'
46          ],
47          'findIndex': [
48            'called with context'
49          ],
50          'findLastIndex': [
51            'called with context'
52          ],
53          'flatten': [
54            'supports empty arrays',
55            'can flatten nested arrays',
56            'works on an arguments object',
57            'can handle very deep arrays'
58          ],
59          'indexOf': [
60            "sorted indexOf doesn't uses binary search",
61            '0'
62          ],
63          'initial': [
64            'returns all but the last n elements',
65            'returns an empty array when n > length',
66            'works on an arguments object'
67          ],
68          'intersection': [
69            'can perform an OO-style intersection'
70          ],
71          'last': [
72            'returns an empty array when n <= 0 (0 case)',
73            'returns an empty array when n <= 0 (negative case)',
74            'can fetch the last n elements',
75            'returns the whole array if n > length'
76          ],
77          'lastIndexOf': [
78            'should treat falsey `fromIndex` values, except `0` and `NaN`, as `array.length`',
79            'should treat non-number `fromIndex` values as `array.length`',
80            '[0,-1,-1]'
81          ],
82          'object': [
83            'an array of pairs zipped together into an object',
84            'an object converted to pairs and back to an object'
85          ],
86          'rest': [
87            'returns the whole array when index is 0',
88            'returns elements starting at the given index',
89            'works on an arguments object'
90          ],
91          'sortedIndex': [
92            '2',
93            '3'
94          ],
95          'tail': [
96            'is an alias for rest'
97          ],
98          'take': [
99            'is an alias for first'
100          ],
101          'uniq': [
102            'uses the result of `iterator` for uniqueness comparisons (unsorted case)',
103            '`sorted` argument defaults to false when omitted',
104            'when `iterator` is a string, uses that key for comparisons (unsorted case)',
105            'uses the result of `iterator` for uniqueness comparisons (sorted case)',
106            'when `iterator` is a string, uses that key for comparisons (sorted case)',
107            'can use falsey pluck like iterator'
108          ],
109          'union': [
110            'can perform an OO-style union'
111          ]
112        },
113        'Chaining': {
114          'pop': true,
115          'shift': true,
116          'splice': true,
117          'reverse/concat/unshift/pop/map': [
118            'can chain together array functions.'
119          ]
120        },
121        'Collections': {
122          'lookupIterator with contexts': true,
123          'Iterating objects with sketchy length properties': true,
124          'Resistant to collection length and properties changing while iterating': true,
125          'countBy': [
126            '{}',
127            '[{}]'
128          ],
129          'each': [
130            'context object property accessed'
131          ],
132          'every': [
133            'Can be called with object',
134            'Died on test #15',
135            'context works'
136          ],
137          'filter': [
138            'given context',
139            'OO-filter'
140          ],
141          'find': [
142            'called with context'
143          ],
144          'findWhere': [
145            'checks properties given function'
146          ],
147          'groupBy': [
148            '{}',
149            '[{}]'
150          ],
151          'includes': [
152            "doesn't delegate to binary search"
153          ],
154          'invoke': [
155            'handles null & undefined'
156          ],
157          'map': [
158            'tripled numbers with context',
159            'OO-style doubled numbers'
160          ],
161          'max': [
162            'can handle null/undefined',
163            'can perform a computation-based max',
164            'Maximum value of an empty object',
165            'Maximum value of an empty array',
166            'Maximum value of a non-numeric collection',
167            'Finds correct max in array starting with num and containing a NaN',
168            'Finds correct max in array starting with NaN',
169            'Respects iterator return value of -Infinity',
170            'String keys use property iterator',
171            'Iterator context',
172            'Lookup falsy iterator'
173          ],
174          'min': [
175            'can handle null/undefined',
176            'can perform a computation-based min',
177            'Minimum value of an empty object',
178            'Minimum value of an empty array',
179            'Minimum value of a non-numeric collection',
180            'Finds correct min in array starting with NaN',
181            'Respects iterator return value of Infinity',
182            'String keys use property iterator',
183            'Iterator context',
184            'Lookup falsy iterator'
185          ],
186          'partition': [
187            'can reference the array index',
188            'Died on test #8',
189            'partition takes a context argument'
190          ],
191          'pluck': [
192            '[1]'
193          ],
194          'reduce': [
195            'can reduce with a context object'
196          ],
197          'reject': [
198            'Returns empty list given empty array'
199          ],
200          'sample': [
201            'behaves correctly on negative n',
202            'Died on test #3'
203          ],
204          'some': [
205            'Can be called with object',
206            'Died on test #17',
207            'context works'
208          ],
209          'where': [
210            'checks properties given function'
211          ],
212          'Can use various collection methods on NodeLists': [
213            '<span id="id2"></span>'
214          ]
215        },
216        'Functions': {
217          'debounce asap': true,
218          'debounce asap cancel': true,
219          'debounce asap recursively': true,
220          'debounce after system time is set backwards': true,
221          'debounce re-entrant': true,
222          'throttle repeatedly with results': true,
223          'more throttle does not trigger leading call when leading is set to false': true,
224          'throttle does not trigger trailing call when trailing is set to false': true,
225          'before': true,
226          'bind': [
227            'Died on test #2'
228          ],
229          'bindAll': [
230            'throws an error for bindAll with no functions named'
231          ],
232          'debounce': [
233            'incr was debounced'
234          ],
235          'iteratee': [
236            '"bbiz"',
237            '"foo"',
238            '1'
239          ],
240          'memoize': [
241            '{"bar":"BAR","foo":"FOO"}',
242            'Died on test #8'
243          ]
244        },
245        'Objects': {
246          '#1929 Typed Array constructors are functions': true,
247          'allKeys': [
248            'is not fooled by sparse arrays; see issue #95',
249            'is not fooled by sparse arrays with additional properties',
250            '[]'
251          ],
252          'extend': [
253            'extending null results in null',
254            'extending undefined results in undefined'
255          ],
256          'extendOwn': [
257            'extending non-objects results in returning the non-object value',
258            'extending undefined results in undefined'
259          ],
260          'functions': [
261            'also looks up functions on the prototype'
262          ],
263          'isEqual': [
264            '`0` is not equal to `-0`',
265            'Commutative equality is implemented for `0` and `-0`',
266            '`new Number(0)` and `-0` are not equal',
267            'Commutative equality is implemented for `new Number(0)` and `-0`',
268            'Invalid dates are not equal',
269            'false'
270          ],
271          'isFinite': [
272            'Numeric strings are numbers',
273            'Number instances can be finite'
274          ],
275          'isSet': [
276            'Died on test #9'
277          ],
278          'findKey': [
279            'called with context'
280          ],
281          'keys': [
282            'is not fooled by sparse arrays; see issue #95',
283            '[]'
284          ],
285          'mapObject': [
286            'keep context',
287            'called with context',
288            'mapValue identity'
289          ],
290          'omit': [
291            'can accept a predicate',
292            'function is given context'
293          ],
294          'pick': [
295            'can accept a predicate and context',
296            'function is given context'
297          ]
298        },
299        'Utility': {
300          '_.escape & unescape': [
301            '` is escaped',
302            '` can be unescaped',
303            'can escape multiple occurances of `',
304            'multiple occurrences of ` can be unescaped'
305          ],
306          'now': [
307            'Produces the correct time in milliseconds'
308          ],
309          'times': [
310            'works as a wrapper'
311          ]
312        }
313      };
314
315      var mixinPrereqs = (function() {
316        var aliasToReal = {
317          'all': 'every',
318          'allKeys': 'keysIn',
319          'any': 'some',
320          'collect': 'map',
321          'compose': 'flowRight',
322          'contains': 'includes',
323          'detect': 'find',
324          'extendOwn': 'assign',
325          'findWhere': 'find',
326          'foldl': 'reduce',
327          'foldr': 'reduceRight',
328          'include': 'includes',
329          'indexBy': 'keyBy',
330          'inject': 'reduce',
331          'invoke': 'invokeMap',
332          'mapObject': 'mapValues',
333          'matcher': 'matches',
334          'methods': 'functions',
335          'object': 'zipObject',
336          'pairs': 'toPairs',
337          'pluck': 'map',
338          'restParam': 'restArgs',
339          'select': 'filter',
340          'unique': 'uniq',
341          'where': 'filter'
342        };
343
344        var keyMap = {
345          'rest': 'tail',
346          'restArgs': 'rest'
347        };
348
349        var lodash = _.noConflict();
350
351        return function(_) {
352          lodash(_)
353            .defaultsDeep({ 'templateSettings': lodash.templateSettings })
354            .mixin(lodash.pick(lodash, lodash.difference(lodash.functions(lodash), lodash.functions(_))))
355            .value();
356
357          lodash.forOwn(keyMap, function(realName, otherName) {
358            _[otherName] = lodash[realName];
359            _.prototype[otherName] = lodash.prototype[realName];
360          });
361          lodash.forOwn(aliasToReal, function(realName, alias) {
362            _[alias] = _[realName];
363            _.prototype[alias] = _.prototype[realName];
364          });
365          return _;
366        };
367      }());
368
369      // Only excuse in Sauce Labs.
370      if (!ui.isSauceLabs) {
371        delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false'];
372        delete QUnit.config.excused.Utility.now;
373      }
374      // Load prerequisite scripts.
375      document.write(ui.urlParams.loader == 'none'
376        ? '<script src="' + ui.buildPath + '"><\/script>'
377        : '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
378      );
379    </script>
380    <script>
381      if (ui.urlParams.loader == 'none') {
382        mixinPrereqs(_);
383        document.write([
384          '<script src="../vendor/underscore/test/collections.js"><\/script>',
385          '<script src="../vendor/underscore/test/arrays.js"><\/script>',
386          '<script src="../vendor/underscore/test/functions.js"><\/script>',
387          '<script src="../vendor/underscore/test/objects.js"><\/script>',
388          '<script src="../vendor/underscore/test/cross-document.js"><\/script>',
389          '<script src="../vendor/underscore/test/utility.js"><\/script>',
390          '<script src="../vendor/underscore/test/chaining.js"><\/script>'
391        ].join('\n'));
392      }
393    </script>
394    <script>
395      (function() {
396        if (window.curl) {
397          curl.config({ 'apiName': 'require' });
398        }
399        if (!window.require) {
400          return;
401        }
402        // Wrap to work around tests assuming Node `require` use.
403        require = (function(func) {
404          return function() {
405            return arguments[0] === '..' ? window._ : func.apply(null, arguments);
406          };
407        }(require));
408
409        var reBasename = /[\w.-]+$/,
410            basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
411            modulePath = ui.buildPath.replace(/\.js$/, ''),
412            locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
413            moduleId = /\bunderscore\b/i.test(ui.buildPath) ? 'underscore' : 'lodash',
414            moduleMain = modulePath.match(reBasename)[0],
415            uid = +new Date;
416
417        function getConfig() {
418          var result = {
419            'baseUrl': './',
420            'urlArgs': 't=' + uid++,
421            'waitSeconds': 0,
422            'paths': {},
423            'packages': [{
424              'name': 'test',
425              'location': '../vendor/underscore/test',
426              'config': {
427                // Work around no global being exported.
428                'exports': 'QUnit',
429                'loader': 'curl/loader/legacy'
430              }
431            }]
432          };
433
434          if (ui.isModularize) {
435            result.packages.push({
436              'name': moduleId,
437              'location': locationPath,
438              'main': moduleMain
439            });
440          } else {
441            result.paths[moduleId] = modulePath;
442          }
443          return result;
444        }
445
446        QUnit.config.autostart = false;
447        QUnit.config.excused.Functions.iteratee = true;
448        QUnit.config.excused.Utility.noConflict = true;
449        QUnit.config.excused.Utility['noConflict (node vm)'] = true;
450
451        require(getConfig(), [moduleId], function(lodash) {
452          _ = mixinPrereqs(lodash);
453          require(getConfig(), [
454            'test/collections',
455            'test/arrays',
456            'test/functions',
457            'test/objects',
458            'test/cross-document',
459            'test/utility',
460            'test/chaining'
461          ], QUnit.start);
462        });
463      }());
464    </script>
465  </body>
466</html>
467