lodash: Add unit tests. [jddalton]

Former-commit-id: 2c4c8e56bb4afaf19d4da520b2fa995b30251401
This commit is contained in:
John-David Dalton
2012-04-22 17:00:14 -04:00
parent 89f82359c1
commit 56b2d76eec
4 changed files with 157 additions and 99 deletions

View File

@@ -70,7 +70,7 @@
toString = ObjProto.toString,
unshift = ArrayProto.unshift;
/* Native method shortcuts for methods with the same name as a `lodash` method */
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeIsArray = Array.isArray,
nativeIsFinite = window.isFinite,
nativeKeys = Object.keys;
@@ -617,7 +617,7 @@
*/
var reduce = iterationFactory({
'args': 'collection,callback,accumulator,thisArg',
'top': 'var initial=arguments.length>2;\n' + forEachFactoryOptions.top,
'top': 'var initial=arguments.length>2;\nif(thisArg)callback=bind(callback,thisArg)',
'init': 'accumulator',
'beforeLoop': {
'array': 'if(!initial)result=collection[++index]'
@@ -654,9 +654,7 @@
if (collection == undefined) {
return result;
}
if (!callback) {
callback = identity;
} else if(thisArg) {
if(thisArg) {
callback = bind(callback, thisArg);
}
var length = collection.length;