-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const test = require('./config') | ||
const { accum } = require('..') | ||
|
||
test('accum transforms simple reducer to accumulator', t=>{ | ||
const add = accum((state,v)=>state+v)(10) | ||
t.is(add(1),10+1) | ||
t.is(add(2),10+1+2) | ||
t.is(add(-1),10+1+2-1) | ||
}) | ||
|
||
test('accum works with reducer with variadic tuples of values', t=>{ | ||
const concat = accum((arr, ...rest)=>arr.concat(rest))([0]) | ||
t.deepEqual(concat(1),[0,1]) | ||
t.deepEqual(concat(),[0,1]) | ||
t.deepEqual(concat(1,2,3),[0,1,1,2,3]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
const test = require('./config') | ||
const { multiCurry2 } = require('..') | ||
const { curryGroups2 } = require('..') | ||
|
||
test('multiCurry2 arg function', t => { | ||
t.is( multiCurry2((a,b)=>a+b)(1)(2), 3) | ||
test('curryGroups2 arg function', t => { | ||
t.is( curryGroups2((a,b)=>a+b)(1)(2), 3) | ||
}) | ||
|
||
test('multiCurry2 3 arg function', t => { | ||
t.is( multiCurry2((a,b,c)=>a+b+c)(1,2)(3), 6) | ||
test('curryGroups2 3 arg function', t => { | ||
t.is( curryGroups2((a,b,c)=>a+b+c)(1,2)(3), 6) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
const test = require('./config') | ||
const { multiCurryN } = require('..') | ||
const { curryGroupsN } = require('..') | ||
|
||
const add = (x,y)=>x+y | ||
const collect = (...args) => args | ||
|
||
test('multiCurryN(1) does not change function', t=>{ | ||
t.is(multiCurryN(1)(add)(11,22), 11+22) | ||
t.deepEqual(multiCurryN(1)(collect)(11,22), [11,22]) | ||
test('curryGroupsN(1) does not change function', t=>{ | ||
t.is(curryGroupsN(1)(add)(11,22), 11+22) | ||
t.deepEqual(curryGroupsN(1)(collect)(11,22), [11,22]) | ||
}) | ||
|
||
test('multiCurryN applied to 2 groups of args', t=>{ | ||
t.deepEqual(multiCurryN(2)(collect)(11)(22), [11,22]) | ||
t.deepEqual(multiCurryN(2)(collect)(11,2)(22,3,1), [11,2,22,3,1]) | ||
test('curryGroupsN applied to 2 groups of args', t=>{ | ||
t.deepEqual(curryGroupsN(2)(collect)(11)(22), [11,22]) | ||
t.deepEqual(curryGroupsN(2)(collect)(11,2)(22,3,1), [11,2,22,3,1]) | ||
}) | ||
|
||
test('multiCurryN applied to 3 groups of args', t=>{ | ||
t.deepEqual(multiCurryN(3)(collect)(11,2)(22)(3,1), [11,2,22,3,1]) | ||
test('curryGroupsN applied to 3 groups of args', t=>{ | ||
t.deepEqual(curryGroupsN(3)(collect)(11,2)(22)(3,1), [11,2,22,3,1]) | ||
}) | ||
|
||
test('multiCurryN applied to 4 groups of args', t=>{ | ||
t.deepEqual(multiCurryN(4)(collect)(11,2)(22)(3)(1), [11,2,22,3,1]) | ||
test('curryGroupsN applied to 4 groups of args', t=>{ | ||
t.deepEqual(curryGroupsN(4)(collect)(11,2)(22)(3)(1), [11,2,22,3,1]) | ||
}) |