summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-01-18 10:27:27 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-01-18 10:32:36 -0800
commit8abeffa9ea5626e81d2d9d0164b2a43ea458a0b8 (patch)
treedb3a7b53aeb4823e5f55038e3433a036009473c8 /test
parentaeb7d6d168204d5d37a7dd9fc4f9dc78a0e83a08 (diff)
downloadnode-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.js28
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);
+});