moy-fp
Version:
A functional programming library.
31 lines (25 loc) • 661 B
JavaScript
import __ from '../../src/Function/__'
/**
* ((a, b, ..., m) -> n) -> ((b, a, ..., m) -> n)
*/
import flip from '../../src/Function/flip'
test('flip(not using __), the original arity is 1', () => {
expect(
flip(a => [a])(1)
).toEqual([undefined])
})
test('flip(not using __), the original arities are 2', () => {
expect(
flip((a, b) => [a, b])(1)(2)
).toEqual([2, 1])
})
test('flip(not using __), the original arities are 3', () => {
expect(
flip((a, b, c) => [a, b, c])(1)(2)(3)
).toEqual([2, 1, 3])
})
test('flip(using __), the original arity is 2', () => {
expect(
flip(__)((a, b) => [a, b])(1)(2)
).toEqual([2, 1])
})