Skip to content

Commit

Permalink
Merge pull request caolan#533 from nazomikan/patch
Browse files Browse the repository at this point in the history
add spec for caolan#303
  • Loading branch information
Caolan McMahon committed May 27, 2014
2 parents 66ca10e + 2bcb2f1 commit 2321212
Showing 1 changed file with 81 additions and 0 deletions.
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

0 comments on commit 2321212

Please sign in to comment.