Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized waterfall, parallel, et al. #1395

Merged
merged 12 commits into from Apr 7, 2017
32 changes: 31 additions & 1 deletion mocha_test/waterfall.js
Expand Up @@ -93,7 +93,6 @@ describe("waterfall", function () {
it('multiple callback calls', function(){
var arr = [
function(callback){
// call the callback twice. this should call function 2 twice
callback(null, 'one', 'two');
callback(null, 'one', 'two');
},
Expand All @@ -106,6 +105,37 @@ describe("waterfall", function () {
}).to.throw(/already called/);
});

it('multiple callback calls (trickier) @nodeonly', function(done){
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suguru03 I think neo-async fails on this test case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it, thanks. :)


// do a weird dance to catch the async thrown error before mocha
var listeners = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException');
process.once('uncaughtException', function onErr(err) {
listeners.forEach(function(listener) {
process.on('uncaughtException', listener);
});
// can't throw errors in a uncaughtException handler, defer
setTimeout(checkErr, 0, err)
})

function checkErr(err) {
expect(err.message).to.match(/already called/);
done();
}

async.waterfall([
function(callback){
setTimeout(callback, 0, null, 'one', 'two');
setTimeout(callback, 10, null, 'one', 'two');
},
function(arg1, arg2, callback){
setTimeout(callback, 15, null, arg1, arg2, 'three');
}
], function () {
throw new Error('should not get here')
});
});

it('call in another context @nycinvalid @nodeonly', function(done) {
var vm = require('vm');
var sandbox = {
Expand Down