Permalink
Browse files

modify test (replace to setImmediate)

  • Loading branch information...
1 parent d5fdddb commit 8b4c7a80a5d3fbcbed8696cd9f0990d27fe5c911 @tasogarepg committed Mar 16, 2013
Showing with 38 additions and 15 deletions.
  1. +28 −5 README.md
  2. +10 −10 test/node-block.test.js
View
@@ -11,7 +11,7 @@ Easily parallel execution and error handling.
```js
var fs = require('fs');
-var block = require('node-block.js').block;
+var block = require('node-block').block;
block(
function() {
@@ -31,7 +31,7 @@ Function name is `cat` and `fin`.
```js
var fs = require('fs');
-var block = require('node-block.js').block;
+var block = require('node-block').block;
block(
function() {
@@ -57,7 +57,7 @@ call `this.end()` with return.
```js
var fs = require('fs');
-var block = require('node-block.js').block;
+var block = require('node-block').block;
block(
function() {
@@ -83,7 +83,7 @@ sample() is called after fin().
```js
var fs = require('fs');
-var block = require('node-block.js').block;
+var block = require('node-block').block;
block(
function() {
@@ -104,7 +104,7 @@ function sample(err){
```js
var fs = require('fs');
-var block = require('node-block.js').block;
+var block = require('node-block').block;
block(
function() {
@@ -131,6 +131,29 @@ block(
)();
```
+### setTimeout
+
+```js
+var block = require('node-block').block;
+
+block(
+ function() {
+ var cb1 = this.async('d1');
+ setTimeout(function() {
+ try {
+ cb1(null, 'abc');
+ } catch (e) {
+ cb1(e);
+ }
+ }, 1000);
+ },
+ function() {
+ var str = this.data.d1;
+ console.log(str); // abc
+ }
+)();
+```
+
## License
The MIT License
View
@@ -432,22 +432,22 @@ describe('node-block', function() {
}
block(
function() {
- process.nextTick(this.async());
+ setImmediate(this.async());
},
function() {
- process.nextTick(this.async());
- process.nextTick(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
},
function() {
- process.nextTick(this.async());
- process.nextTick(this.async());
- process.nextTick(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
},
function() {
- process.nextTick(this.async());
- process.nextTick(this.async());
- process.nextTick(this.async());
- process.nextTick(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
+ setImmediate(this.async());
}
)(serialLoop);
})();

0 comments on commit 8b4c7a8

Please sign in to comment.