Skip to content

Commit

Permalink
more succinct arity assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Sep 23, 2016
1 parent 23805c8 commit c465bdd
Show file tree
Hide file tree
Showing 106 changed files with 115 additions and 424 deletions.
5 changes: 1 addition & 4 deletions test/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('A', function() {

it('is a binary function', function() {
eq(typeof S.A, 'function');
eq(S.A.length, 2);
});
utils.assertBinaryFunction(S.A);

it('A(f, x) is equivalent to f(x)', function() {
eq(S.A(S.inc, 1), 2);
Expand Down
5 changes: 1 addition & 4 deletions test/C.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('C', function() {

it('is a ternary function', function() {
eq(typeof S.C, 'function');
eq(S.C.length, 3);
});
utils.assertTernaryFunction(S.C);

it('C(f, x, y) is equivalent to f(y)(x)', function() {
eq(S.C(S.concat, 'foo', 'bar'), 'barfoo');
Expand Down
5 changes: 1 addition & 4 deletions test/I.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('I', function() {

it('is a unary function', function() {
eq(typeof S.I, 'function');
eq(S.I.length, 1);
});
utils.assertUnaryFunction(S.I);

it('returns its argument', function() {
eq(S.I([1, 2, 3]), [1, 2, 3]);
Expand Down
5 changes: 1 addition & 4 deletions test/K.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('K', function() {

it('is a binary function', function() {
eq(typeof S.K, 'function');
eq(S.K.length, 2);
});
utils.assertBinaryFunction(S.K);

it('returns its first argument', function() {
eq(S.K(21, []), 21);
Expand Down
5 changes: 1 addition & 4 deletions test/S.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('S', function() {

it('is a ternary function', function() {
eq(typeof S.C, 'function');
eq(S.C.length, 3);
});
utils.assertTernaryFunction(S.S);

it('S(f, g, x) is equivalent to f(x)(g(x))', function() {
eq(S.S(S.add, Math.sqrt, 100), 110);
Expand Down
5 changes: 1 addition & 4 deletions test/T.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ var eq = utils.eq;

describe('T', function() {

it('is a binary function', function() {
eq(typeof S.T, 'function');
eq(S.T.length, 2);
});
utils.assertBinaryFunction(S.T);

it('T(x, f) is equivalent to f(x)', function() {
eq(S.T(42, S.inc), 43);
Expand Down
5 changes: 1 addition & 4 deletions test/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('add', function() {

it('is a binary function', function() {
eq(typeof S.add, 'function');
eq(S.add.length, 2);
});
utils.assertBinaryFunction(S.add);

it('type checks its arguments', function() {
throws(function() { S.add('xxx', 1); },
Expand Down
5 changes: 1 addition & 4 deletions test/allPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('allPass', function() {

it('is a binary function', function() {
eq(typeof S.allPass, 'function');
eq(S.allPass.length, 2);
});
utils.assertBinaryFunction(S.allPass);

it('type checks its arguments', function() {
throws(function() { S.allPass('wrong'); },
Expand Down
5 changes: 1 addition & 4 deletions test/and.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('and', function() {

it('is a binary function', function() {
eq(typeof S.and, 'function');
eq(S.and.length, 2);
});
utils.assertBinaryFunction(S.and);

it('can be applied to Booleans', function() {
eq(S.and(false, false), false);
Expand Down
5 changes: 1 addition & 4 deletions test/anyPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('anyPass', function() {

it('is a binary function', function() {
eq(typeof S.anyPass, 'function');
eq(S.anyPass.length, 2);
});
utils.assertBinaryFunction(S.anyPass);

it('type checks its arguments', function() {
throws(function() { S.anyPass('wrong'); },
Expand Down
5 changes: 1 addition & 4 deletions test/append.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('append', function() {

it('is a binary function', function() {
eq(typeof S.append, 'function');
eq(S.append.length, 2);
});
utils.assertBinaryFunction(S.append);

it('type checks its arguments', function() {
throws(function() { S.append('c', 'ab'); },
Expand Down
5 changes: 1 addition & 4 deletions test/at.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('at', function() {

it('is a binary function', function() {
eq(typeof S.at, 'function');
eq(S.at.length, 2);
});
utils.assertBinaryFunction(S.at);

it('type checks its arguments', function() {
throws(function() { S.at(0.5); },
Expand Down
5 changes: 1 addition & 4 deletions test/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('concat', function() {

it('is a binary function', function() {
eq(typeof S.concat, 'function');
eq(S.concat.length, 2);
});
utils.assertBinaryFunction(S.concat);

it('type checks its arguments', function() {
throws(function() { S.concat(/XXX/); },
Expand Down
5 changes: 1 addition & 4 deletions test/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ var uncheckedCustomEnv = S.create({checkTypes: false, env: customEnv});

describe('create', function() {

it('is a unary function', function() {
eq(typeof S.create, 'function');
eq(S.create.length, 1);
});
utils.assertUnaryFunction(S.create);

it('type checks its arguments', function() {
throws(function() { S.create({}); },
Expand Down
5 changes: 1 addition & 4 deletions test/dec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('dec', function() {

it('is a unary function', function() {
eq(typeof S.dec, 'function');
eq(S.dec.length, 1);
});
utils.assertUnaryFunction(S.dec);

it('type checks its arguments', function() {
throws(function() { S.dec('xxx'); },
Expand Down
5 changes: 1 addition & 4 deletions test/div.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('div', function() {

it('is a binary function', function() {
eq(typeof S.div, 'function');
eq(S.div.length, 2);
});
utils.assertBinaryFunction(S.div);

it('type checks its arguments', function() {
throws(function() { S.div('xxx', 1); },
Expand Down
5 changes: 1 addition & 4 deletions test/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('drop', function() {

it('is a binary function', function() {
eq(typeof S.drop, 'function');
eq(S.drop.length, 2);
});
utils.assertBinaryFunction(S.drop);

it('type checks its arguments', function() {
throws(function() { S.drop(0.5); },
Expand Down
5 changes: 1 addition & 4 deletions test/dropLast.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('dropLast', function() {

it('is a binary function', function() {
eq(typeof S.dropLast, 'function');
eq(S.dropLast.length, 2);
});
utils.assertBinaryFunction(S.dropLast);

it('type checks its arguments', function() {
throws(function() { S.dropLast(0.5); },
Expand Down
5 changes: 1 addition & 4 deletions test/either.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('either', function() {

it('is a ternary function', function() {
eq(typeof S.either, 'function');
eq(S.either.length, 3);
});
utils.assertTernaryFunction(S.either);

it('type checks its arguments', function() {
throws(function() { S.either([1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/eitherToMaybe.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('eitherToMaybe', function() {

it('is a unary function', function() {
eq(typeof S.eitherToMaybe, 'function');
eq(S.eitherToMaybe.length, 1);
});
utils.assertUnaryFunction(S.eitherToMaybe);

it('type checks its arguments', function() {
throws(function() { S.eitherToMaybe(/XXX/); },
Expand Down
5 changes: 1 addition & 4 deletions test/encase.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ var factorial = utils.factorial;

describe('encase', function() {

it('is a binary function', function() {
eq(typeof S.encase, 'function');
eq(S.encase.length, 2);
});
utils.assertBinaryFunction(S.encase);

it('type checks its arguments', function() {
throws(function() { S.encase([1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/encase2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ var rem = utils.rem;

describe('encase2', function() {

it('is a ternary function', function() {
eq(typeof S.encase2, 'function');
eq(S.encase2.length, 3);
});
utils.assertTernaryFunction(S.encase2);

it('type checks its arguments', function() {
throws(function() { S.encase2([1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/encase3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ var highArity = utils.highArity;

describe('encase3', function() {

it('is a quaternary function', function() {
eq(typeof S.encase3, 'function');
eq(S.encase3.length, 4);
});
utils.assertQuaternaryFunction(S.encase3);

it('type checks its arguments', function() {
throws(function() { S.encase3([1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/encaseEither.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ var factorial = utils.factorial;

describe('encaseEither', function() {

it('is a ternary function', function() {
eq(typeof S.encaseEither, 'function');
eq(S.encaseEither.length, 3);
});
utils.assertTernaryFunction(S.encaseEither);

it('type checks its arguments', function() {
throws(function() { S.encaseEither(null); },
Expand Down
5 changes: 1 addition & 4 deletions test/encaseEither2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ var rem = utils.rem;

describe('encaseEither2', function() {

it('is a quaternary function', function() {
eq(typeof S.encaseEither2, 'function');
eq(S.encaseEither2.length, 4);
});
utils.assertQuaternaryFunction(S.encaseEither2);

it('type checks its arguments', function() {
throws(function() { S.encaseEither2(null); },
Expand Down
5 changes: 1 addition & 4 deletions test/encaseEither3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ var highArity = utils.highArity;

describe('encaseEither3', function() {

it('is a quinary function', function() {
eq(typeof S.encaseEither3, 'function');
eq(S.encaseEither3.length, 5);
});
utils.assertQuinaryFunction(S.encaseEither3);

it('type checks its arguments', function() {
throws(function() { S.encaseEither3(null); },
Expand Down
5 changes: 1 addition & 4 deletions test/even.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('even', function() {

it('is a unary function', function() {
eq(typeof S.even, 'function');
eq(S.even.length, 1);
});
utils.assertUnaryFunction(S.even);

it('type checks its arguments', function() {
throws(function() { S.even(0.5); },
Expand Down
5 changes: 1 addition & 4 deletions test/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('filter', function() {

it('is a binary function', function() {
eq(typeof S.filter, 'function');
eq(S.filter.length, 2);
});
utils.assertBinaryFunction(S.filter);

it('type checks its arguments', function() {
throws(function() { S.filter(S.odd, S.Right(0)); },
Expand Down
5 changes: 1 addition & 4 deletions test/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('find', function() {

it('is a binary function', function() {
eq(typeof S.find, 'function');
eq(S.find.length, 2);
});
utils.assertBinaryFunction(S.find);

it('type checks its arguments', function() {
throws(function() { S.find([1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/flip.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('flip', function() {

it('is a ternary function', function() {
eq(typeof S.flip, 'function');
eq(S.flip.length, 3);
});
utils.assertTernaryFunction(S.flip);

it('throws if applied to values of different types', function() {
throws(function() { S.flip('wrong'); },
Expand Down
5 changes: 1 addition & 4 deletions test/fromEither.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ var eq = utils.eq;

describe('fromEither', function() {

it('is a binary function', function() {
eq(typeof S.fromEither, 'function');
eq(S.fromEither.length, 2);
});
utils.assertBinaryFunction(S.fromEither);

it('type checks its arguments', function() {
throws(function() { S.fromEither(0, [1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/fromMaybe.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ var errorEq = utils.errorEq;

describe('fromMaybe', function() {

it('is a binary function', function() {
eq(typeof S.fromMaybe, 'function');
eq(S.fromMaybe.length, 2);
});
utils.assertBinaryFunction(S.fromMaybe);

it('type checks its arguments', function() {
throws(function() { S.fromMaybe(0, [1, 2, 3]); },
Expand Down
5 changes: 1 addition & 4 deletions test/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ var errorEq = utils.errorEq;

describe('get', function() {

it('is a ternary function', function() {
eq(typeof S.get, 'function');
eq(S.get.length, 3);
});
utils.assertTernaryFunction(S.get);

it('type checks its arguments', function() {
throws(function() { S.get([1, 2, 3]); },
Expand Down
Loading

0 comments on commit c465bdd

Please sign in to comment.