deno.land / x / rambda@v9.1.1 / source / either.spec.js

either.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { either } from './either.js'
test('with multiple inputs', () => { const between = function ( a, b, c ){ return a < b && b < c } const total20 = function ( a, b, c ){ return a + b + c === 20 } const fn = either(between, total20) expect(fn( 7, 8, 5 )).toBeTrue()})
test('skip evaluation of the second expression', () => { let effect = 'not evaluated' const F = function (){ return true } const Z = function (){ effect = 'Z got evaluated' } either(F, Z)()
expect(effect).toBe('not evaluated')})
test('case 1', () => { const firstFn = val => val > 0 const secondFn = val => val * 5 > 10
expect(either(firstFn, secondFn)(1)).toBeTrue()})
test('case 2', () => { const firstFn = val => val > 0 const secondFn = val => val === -10 const fn = either(firstFn)(secondFn)
expect(fn(-10)).toBeTrue()})
rambda

Version Info

Tagged at
2 months ago