diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-01-18 10:27:27 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-01-18 10:32:36 -0800 |
commit | 8abeffa9ea5626e81d2d9d0164b2a43ea458a0b8 (patch) | |
tree | db3a7b53aeb4823e5f55038e3433a036009473c8 /test | |
parent | aeb7d6d168204d5d37a7dd9fc4f9dc78a0e83a08 (diff) | |
download | node-8abeffa9ea5626e81d2d9d0164b2a43ea458a0b8.tar.gz |
Add process.nextTick()
This is a replacement for the common hack:
setTimeout(cb, 0);
It's much more efficient.
Diffstat (limited to 'test')
-rw-r--r-- | test/mjsunit/test-next-tick.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/mjsunit/test-next-tick.js b/test/mjsunit/test-next-tick.js new file mode 100644 index 000000000..1dd20574a --- /dev/null +++ b/test/mjsunit/test-next-tick.js @@ -0,0 +1,28 @@ +process.mixin(require("./common")); + +var complete = 0; + +process.nextTick(function () { + complete++; + process.nextTick(function () { + complete++; + process.nextTick(function () { + complete++; + }); + }); +}); + +setTimeout(function () { + process.nextTick(function () { + complete++; + }); +}, 50); + +process.nextTick(function () { + complete++; +}); + + +process.addListener('exit', function () { + assert.equal(5, complete); +}); |