From 2c48f07a4db814449f8f6333f36815d4c582b746 Mon Sep 17 00:00:00 2001 From: David Chambers Date: Fri, 23 Sep 2016 18:15:34 +0200 Subject: [PATCH] test: rename misnamed files --- test/lift.js | 39 +++++++++++++++------------------- test/lift2.js | 39 +++++++++++++++++++--------------- test/{unfolr.js => unfoldr.js} | 0 3 files changed, 39 insertions(+), 39 deletions(-) rename test/{unfolr.js => unfoldr.js} (100%) diff --git a/test/lift.js b/test/lift.js index 9cb36d9e..01f8bf69 100644 --- a/test/lift.js +++ b/test/lift.js @@ -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); }); }); diff --git a/test/lift2.js b/test/lift2.js index 01f8bf69..9cb36d9e 100644 --- a/test/lift2.js +++ b/test/lift2.js @@ -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); }); }); diff --git a/test/unfolr.js b/test/unfoldr.js similarity index 100% rename from test/unfolr.js rename to test/unfoldr.js