and-not.test.js (896B)
1 const tape = require('tape'); 2 const operators = require('./index'); 3 4 const andNot = operators['AND NOT']; 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(andNot(zero , one )(), 0, '0 &! 1 == 0'); 17 t.equal(andNot(one , two )(), 1, '1 &! 2 == 1'); 18 t.equal(andNot(two , three)(), 2, '2 &! 3 == 2'); 19 t.equal(andNot(three, four )(), 3, '3 &! 4 == 3'); 20 t.equal(andNot(four , five )(), 4, '4 &! 5 == 4'); 21 }); 22 23 tape('Mixing negative numbers', async t => { 24 t.plan(2); 25 t.equal(andNot(minus(two), one )(), -1, '-2 &! 1 == -1'); 26 t.equal(andNot( two , minus(one))(), 1, ' 2 &! -1 == 1'); 27 }); 28 29 tape('Matching abs', async t => { 30 t.plan(1); 31 t.equal(andNot(minus(two), two)(), -2, '-2 &! 2 == -2'); 32 });