Skip to content

Commit

Permalink
test: use internal map function in place of Z.map
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Feb 4, 2017
1 parent 011129f commit 80c0696
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/chainRec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

var Z = require('sanctuary-type-classes');

var S = require('..');

var eq = require('./internal/eq');
var map = require('./internal/map');


test('chainRec', function() {
Expand All @@ -14,15 +13,15 @@ test('chainRec', function() {
eq(S.chainRec.toString(), 'chainRec :: ChainRec m => TypeRep m -> (a -> m (Either a b)) -> a -> m b');

function permute(s) {
return s.length === 2 ? Z.map(S.Right, [s + '!', s + '?'])
: Z.map(S.Left, [s + 'o', s + 'n']);
return s.length === 2 ? map(S.Right)([s + '!', s + '?'])
: map(S.Left)([s + 'o', s + 'n']);
}

eq(S.chainRec(Array, permute, ''), ['oo!', 'oo?', 'on!', 'on?', 'no!', 'no?', 'nn!', 'nn?']);

function stepper(n) {
return n === 3000 ? Z.map(S.Right, function(env) { return n + env.inc; })
: Z.map(S.Left, function(env) { return n + env.step; });
return n === 3000 ? map(S.Right)(function(env) { return n + env.inc; })
: map(S.Left)(function(env) { return n + env.step; });
}

eq(S.chainRec(Function, stepper, 0)({step: 2, inc: 100}), 3100);
Expand Down

0 comments on commit 80c0696

Please sign in to comment.