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

add spec for #303 #533

Merged
merged 3 commits into from
May 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions test/test-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,33 @@ exports['waterfall multiple callback calls'] = function(test){
async.waterfall(arr);
};

exports['waterfall call in another context'] = function(test) {
if (typeof process === 'undefined') {
// node only test
test.done();
return;
}

var vm = require('vm');
var sandbox = {
async: async,
test: test
};

var fn = "(" + (function () {
async.waterfall([function (callback) {
callback();
}], function (err) {
if (err) {
return test.done(err);
}
test.done();
});
}).toString() + "())";

vm.runInNewContext(fn, sandbox);
};


exports['parallel'] = function(test){
var call_order = [];
Expand Down Expand Up @@ -902,6 +929,33 @@ exports['parallel limit object'] = function(test){
});
};

exports['parallel call in another context'] = function(test) {
if (typeof process === 'undefined') {
// node only test
test.done();
return;
}
var vm = require('vm');
var sandbox = {
async: async,
test: test
};

var fn = "(" + (function () {
async.parallel([function (callback) {
callback();
}], function (err) {
if (err) {
return test.done(err);
}
test.done();
});
}).toString() + "())";

vm.runInNewContext(fn, sandbox);
};


exports['series'] = function(test){
var call_order = [];
async.series([
Expand Down Expand Up @@ -978,6 +1032,33 @@ exports['series object'] = function(test){
});
};

exports['series call in another context'] = function(test) {
if (typeof process === 'undefined') {
// node only test
test.done();
return;
}
var vm = require('vm');
var sandbox = {
async: async,
test: test
};

var fn = "(" + (function () {
async.series([function (callback) {
callback();
}], function (err) {
if (err) {
return test.done(err);
}
test.done();
});
}).toString() + "())";

vm.runInNewContext(fn, sandbox);
};


exports['iterator'] = function(test){
var call_order = [];
var iterator = async.iterator([
Expand Down