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