Skip to content

Commit

Permalink
Merge pull request #258 from sanctuary-js/dc-filenames
Browse files Browse the repository at this point in the history
test: rename misnamed files
  • Loading branch information
davidchambers authored Sep 23, 2016
2 parents 018fe84 + 2c48f07 commit d9d0259
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
39 changes: 17 additions & 22 deletions test/lift.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,39 @@ var errorEq = require('./utils').errorEq;
var S = require('..');


describe('lift2', function() {
describe('lift', function() {

it('is a ternary function', function() {
eq(typeof S.lift2, 'function');
eq(S.lift2.length, 3);
it('is a binary function', function() {
eq(typeof S.lift, 'function');
eq(S.lift.length, 2);
});

it('type checks its arguments', function() {
throws(function() { S.lift2('wrong'); },
throws(function() { S.lift('wrong'); },
errorEq(TypeError,
'Invalid value\n' +
'\n' +
'lift2 :: (Apply a, Apply b, Apply c) => Function -> a -> b -> c\n' +
' ^^^^^^^^\n' +
' 1\n' +
'lift :: (Functor a, Functor b) => Function -> a -> b\n' +
' ^^^^^^^^\n' +
' 1\n' +
'\n' +
'1) "wrong" :: String\n' +
'\n' +
'The value at position 1 is not a member of ‘Function’.\n'));
});

it('lifts a function into the context of Applys', function() {
// positive :: Number -> Boolean
var positive = function(n) { return n > 0; };
it('lifts a function into the context of Functors', function() {
eq(S.lift(S.mult(2), S.Just(3)), S.Just(6));
eq(S.lift(S.mult(2), S.Nothing), S.Nothing);

eq(S.lift2(S.add, S.Just(3), S.Just(3)), S.Just(6));
eq(S.lift2(S.add, S.Nothing, S.Just(3)), S.Nothing);
eq(S.lift(S.mult(2), S.Left(3)), S.Left(3));
eq(S.lift(S.mult(2), S.Right(3)), S.Right(6));

eq(S.lift2(S.add, S.Right(3), S.Left(4)), S.Left(4));
eq(S.lift2(S.add, S.Right(3), S.Right(4)), S.Right(7));
eq(S.lift(S.mult(2), [1, 2, 3]), [2, 4, 6]);
eq(S.lift(S.mult(2), []), []);

eq(S.lift2(S.add, [1, 2], [10, 20]), [11, 21, 12, 22]);
eq(S.lift2(S.add, [], [1, 2]), []);

eq(S.lift2(S.and, S.even, positive)(42), true);
eq(S.lift2(S.and, S.even, positive)(43), false);
eq(S.lift2(S.and, S.even, positive)(-42), false);
eq(S.lift2(S.and, S.even, positive)(-43), false);
eq(S.lift(S.not, S.even)(42), false);
eq(S.lift(S.not, S.even)(43), true);
});

});
39 changes: 22 additions & 17 deletions test/lift2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,44 @@ var errorEq = require('./utils').errorEq;
var S = require('..');


describe('lift', function() {
describe('lift2', function() {

it('is a binary function', function() {
eq(typeof S.lift, 'function');
eq(S.lift.length, 2);
it('is a ternary function', function() {
eq(typeof S.lift2, 'function');
eq(S.lift2.length, 3);
});

it('type checks its arguments', function() {
throws(function() { S.lift('wrong'); },
throws(function() { S.lift2('wrong'); },
errorEq(TypeError,
'Invalid value\n' +
'\n' +
'lift :: (Functor a, Functor b) => Function -> a -> b\n' +
' ^^^^^^^^\n' +
' 1\n' +
'lift2 :: (Apply a, Apply b, Apply c) => Function -> a -> b -> c\n' +
' ^^^^^^^^\n' +
' 1\n' +
'\n' +
'1) "wrong" :: String\n' +
'\n' +
'The value at position 1 is not a member of ‘Function’.\n'));
});

it('lifts a function into the context of Functors', function() {
eq(S.lift(S.mult(2), S.Just(3)), S.Just(6));
eq(S.lift(S.mult(2), S.Nothing), S.Nothing);
it('lifts a function into the context of Applys', function() {
// positive :: Number -> Boolean
var positive = function(n) { return n > 0; };

eq(S.lift(S.mult(2), S.Left(3)), S.Left(3));
eq(S.lift(S.mult(2), S.Right(3)), S.Right(6));
eq(S.lift2(S.add, S.Just(3), S.Just(3)), S.Just(6));
eq(S.lift2(S.add, S.Nothing, S.Just(3)), S.Nothing);

eq(S.lift(S.mult(2), [1, 2, 3]), [2, 4, 6]);
eq(S.lift(S.mult(2), []), []);
eq(S.lift2(S.add, S.Right(3), S.Left(4)), S.Left(4));
eq(S.lift2(S.add, S.Right(3), S.Right(4)), S.Right(7));

eq(S.lift(S.not, S.even)(42), false);
eq(S.lift(S.not, S.even)(43), true);
eq(S.lift2(S.add, [1, 2], [10, 20]), [11, 21, 12, 22]);
eq(S.lift2(S.add, [], [1, 2]), []);

eq(S.lift2(S.and, S.even, positive)(42), true);
eq(S.lift2(S.and, S.even, positive)(43), false);
eq(S.lift2(S.and, S.even, positive)(-42), false);
eq(S.lift2(S.and, S.even, positive)(-43), false);
});

});
File renamed without changes.

0 comments on commit d9d0259

Please sign in to comment.