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