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