Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more test cases

  • Loading branch information...
commit 2084237436864eb85e59e78b750c96a4dfa582cc 1 parent e3da6b9
Tim authored
Showing with 28 additions and 7 deletions.
  1. +28 −7 test.js
35 test.js
View
@@ -1,10 +1,34 @@
var parallel = require('./lib/parallel');
+var fs = require('fs');
var sys = require('sys');
-var task = new parallel.Sequence(
+var task = new parallel.Task({
+ 1: [fs.readFile, __filename],
+ 'tick': [process.nextTick]
+});
+
+task.add('dir', [fs.readdir, __dirname]);
+
+task.bind(1, function (err, buffer) {
+ sys.puts('parallel-1: ' + buffer.length);
+});
+
+task.run(function (task_name, err, data) {
+ if (task_name === null) {
+ seq.run(function () {
+ sys.puts('Done.');
+ });
+ } else if (task_name === 'dir') {
+ sys.puts('parallel-dir: ' + data.join(', '))
+ } else if (task_name === 'tick') {
+ sys.puts('parallel-tick');
+ }
+});
+
+var seq = new parallel.Sequence(
function (next) {
- sys.puts('1');
- next('2');
+ sys.puts('sequence-1');
+ next('sequence-2');
},
function (next, text) {
sys.puts(text);
@@ -13,11 +37,8 @@ var task = new parallel.Sequence(
process.nextTick(next.parallel());
},
function (next, err, results) {
- sys.puts('3');
+ sys.puts('sequence-3');
sys.puts(sys.inspect(arguments));
next();
}
);
-task.run(function () {
- sys.puts('Done.');
-});
Please sign in to comment.
Something went wrong with that request. Please try again.