summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/test-async.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/test-async.js b/test/test-async.js
index 6a4e8a3..6a35606 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -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 = [];
@@ -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([
@@ -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([