Skip to content

Commit

Permalink
Implement fixup cadences.
Browse files Browse the repository at this point in the history
Implemented arrayed fixup cadences, completing fixup cadences.

Closes #61.
  • Loading branch information
flatheadmill committed Mar 11, 2013
1 parent cef593c commit 5f13538
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ function factory () {
}
}

function createArray (invocation, arity) {
var callback = { results: [] }, index = 0;
function createArray (invocation, arity, cadence) {
var callback = { results: [], cadence: cadence }, index = 0;
if (arity) callback.arity = arity;
callback.arrayed = true;
invocation.callbacks.push(callback);
Expand Down
26 changes: 17 additions & 9 deletions t/cadence/fixup.t.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
#!/usr/bin/env node

require('proof')(1, function (step, deepEqual) {
require('proof')(2, function (step, deepEqual) {
var fs = require('fs'), cadence = require('../..');

cadence(function (step) {

items(step(step, function (items) {
return items.sort();
}, function (items) {
return items.reverse();
echo(1, step(step, function (number) {
return - number;
}));

}, function (items) {

deepEqual(items, [ 3, 2, 1 ], "inline cadence");
deepEqual(items, -1, 'fixup cadence');

})(step());

cadence(function (step) {

var numbers = step(step, [], function (number) { return - number });
[ 1, 2, 3 ].forEach(function (number) {
echo(number, numbers());
});

}, function (numbers) {

deepEqual(numbers, [ -1, -2, -3 ], 'fixup array cadence');

})(step());
});

function items (callback) {
callback(null, [ 2, 3, 1 ]);
}
function echo (value, callback) { callback(null, value); }

0 comments on commit 5f13538

Please sign in to comment.