Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed async bug for reduce - issue 2
- Loading branch information
1 parent
049dd2e
commit e5d1123
Showing
2 changed files
with
83 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
var assert = require('assert'); | ||
var zo = require('./zo').zo; | ||
require('../cupoftea/cupoftea'); | ||
|
||
spec('integers', function () { | ||
var i = 0; | ||
|
||
spec('should be zero', function () { | ||
assert.equal(i, 0); | ||
}); | ||
|
||
spec('should be greater than one', function () { | ||
assert.equal(i, 0); | ||
}); | ||
}); | ||
|
||
spec('reduce left', function () { | ||
var assertCorrectResult = function (result) { | ||
assert.deepEqual(result, [1, 2, 3, 4]); | ||
}; | ||
|
||
spec('async', function () { | ||
zo([1, 2, 3, 4]).reduce([], function(memo, item, into) { | ||
process.nextTick(function() { | ||
memo.push(item); | ||
into(memo); | ||
}); | ||
}).results(shouldCall(assertCorrectResult)); | ||
}); | ||
|
||
spec('sync', function () { | ||
zo([1, 2, 3, 4]).reduce([], function(memo, item, into) { | ||
memo.push(item); | ||
into(memo); | ||
}).results(shouldCall(assertCorrectResult)); | ||
}); | ||
}); | ||
|
||
spec('reduce right', function () { | ||
var assertCorrectResult = function (result) { | ||
assert.deepEqual(result, [4, 3, 2, 1]); | ||
}; | ||
|
||
spec('async', function () { | ||
zo([1, 2, 3, 4]).reduceRight([], function(memo, item, into) { | ||
process.nextTick(function() { | ||
memo.push(item); | ||
into(memo); | ||
}); | ||
}).results(shouldCall(assertCorrectResult)); | ||
}); | ||
|
||
spec('sync', function () { | ||
zo([1, 2, 3, 4]).reduceRight([], function(memo, item, into) { | ||
memo.push(item); | ||
into(memo); | ||
}).results(shouldCall(assertCorrectResult)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters