Update fp mapping with a test to catch potentially missed wrappers.

This commit is contained in:
John-David Dalton
2016-01-15 22:42:08 -08:00
parent fdea9a447f
commit f6c6de40f1
3 changed files with 57 additions and 27 deletions

View File

@@ -99,7 +99,10 @@ function baseConvert(util, name, func) {
var wrappers = { var wrappers = {
'iteratee': function(iteratee) { 'iteratee': function(iteratee) {
return function(func, arity) { return function() {
var func = arguments[0],
arity = arguments[1];
arity = arity > 2 ? (arity - 2) : 1; arity = arity > 2 ? (arity - 2) : 1;
func = iteratee(func); func = iteratee(func);
var length = func.length; var length = func.length;

View File

@@ -74,31 +74,42 @@ module.exports = {
/** Used to map ary to method names. */ /** Used to map ary to method names. */
'aryMethod': { 'aryMethod': {
1: ( 1:[
'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' + 'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' + 'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','), 'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
2: ( 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'unset', 'words'
'add,ary,assign,at,bind,bindKey,chunk,cloneDeepWith,cloneWith,concat,countBy,', ],
'curryN,curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,' + 2:[
'dropRight,dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,' + 'add', 'after', 'ary', 'assign', 'at', 'before', 'bind', 'bindKey',
'find,findIndex,findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,' + 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
'forEachRight,forIn,forInRight,forOwn,forOwnRight,get,groupBy,gt,gte,has,' + 'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
'hasIn,includes,indexBy,indexOf,intersection,invoke,invokeMap,isEqual,' + 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',
'isMatch,lastIndexOf,lt,lte,map,mapKeys,mapValues,matchesProperty,maxBy,' + 'every', 'extend', 'filter', 'find', 'find', 'findIndex', 'findKey',
'mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,padRight,parseInt,' + 'findLast', 'findLastIndex', 'findLastKey', 'flatMap', 'forEach',
'partition,pick,pull,pullAll,pullAt,random,range,rangeRight,rearg,reject,' + 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',
'remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,sortedLastIndexBy,' + 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',
'sortedUniqBy,split,startsWith,subtract,sumBy,take,takeRight,takeRightWhile,' + 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf',
'takeWhile,throttle,times,truncate,union,uniqBy,uniqWith,without,wrap,xor,' + 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy',
'zip,zipObject').split(','), 'mean', 'merge', 'minBy', 'omit', 'orderBy', 'overArgs', 'pad', 'padEnd',
3: ( 'padStart', 'parseInt', 'partition', 'pick', 'pull', 'pullAll', 'pullAt',
'assignWith,assignInWith,clamp,differenceBy,differenceWith,getOr,inRange,' + 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat',
'intersectionBy,intersectionWith,isEqualWith,isMatchWith,mergeWith,omitBy,' + 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf',
'pickBy,pullAllBy,reduce,reduceRight,replace,set,slice,transform,unionBy,' + 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith',
'unionWith,xorBy,xorWith,zipWith').split(','), 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile',
4: 'tap', 'throttle', 'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith',
['fill', 'setWith'] 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject'
],
3:[
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
'isMatchWith', 'mergeWith', 'omitBy', 'pickBy', 'pullAllBy', 'reduce',
'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy',
'transform', 'unionBy', 'unionWith', 'xorBy', 'xorWith', 'zipWith'
],
4:[
'fill', 'setWith'
]
}, },
/** Used to map ary to rearg configs by method ary. */ /** Used to map ary to rearg configs by method ary. */
@@ -119,7 +130,7 @@ module.exports = {
'transform': [2, 0, 1] 'transform': [2, 0, 1]
}, },
/** Used to iterate `mapping.aryMethodMap` keys. */ /** Used to iterate `mapping.aryMethod` keys. */
'caps': [1, 2, 3, 4], 'caps': [1, 2, 3, 4],
/** Used to map keys to other keys. */ /** Used to map keys to other keys. */

View File

@@ -67,6 +67,22 @@
console.log('Running lodash/fp tests.'); console.log('Running lodash/fp tests.');
QUnit.module('method arity checks');
(function() {
QUnit.test('should wrap methods with an arity > `1`', function(assert) {
assert.expect(1);
var methodNames = _.filter(_.functions(fp), function(methodName) {
return fp[methodName].length > 1;
});
assert.deepEqual(methodNames, []);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('method aliases'); QUnit.module('method aliases');
(function() { (function() {