and.test.js (865B)
1 const tape = require('tape'); 2 const operators = require('./index'); 3 4 const and = operators['AND']; 5 6 const minus = n => () => -n(), 7 zero = () => 0, 8 one = () => 1, 9 two = () => 2, 10 three = () => 3, 11 four = () => 4, 12 five = () => 5; 13 14 tape('Verifying positive numbers', async t => { 15 t.plan(5); 16 t.equal(and(zero , one )(), 0, '0 && 1 == 0'); 17 t.equal(and(one , two )(), 1, '1 && 2 == 1'); 18 t.equal(and(two , three)(), 2, '2 && 3 == 2'); 19 t.equal(and(three, four )(), 3, '3 && 4 == 3'); 20 t.equal(and(four , five )(), 4, '4 && 5 == 4'); 21 }); 22 23 tape('Mixing negative numbers', async t => { 24 t.plan(2); 25 t.equal(and(minus(two), one )(), 1, '-2 && 1 == 1'); 26 t.equal(and( two , minus(one))(), -1, ' 2 && -1 == -1'); 27 }); 28 29 tape('Matching abs', async t => { 30 t.plan(1); 31 t.equal(and(minus(two), two)(), -2, '-2 && 2 == -2'); 32 });