summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2015-04-04 01:08:20 +0300
committerFedor Indutny <fedor@indutny.com>2015-04-04 02:31:50 +0300
commit6f72d87c274f28021ba3bf7056d8faa18e75b4f1 (patch)
treef9b720856ff0c01ab63da9861816dcf0ceb056ef /test
parentd22b2a934a62087522511e1e6b66b71370506c77 (diff)
downloadandroid-node-v8-6f72d87c274f28021ba3bf7056d8faa18e75b4f1.tar.gz
android-node-v8-6f72d87c274f28021ba3bf7056d8faa18e75b4f1.tar.bz2
android-node-v8-6f72d87c274f28021ba3bf7056d8faa18e75b4f1.zip
test: add test for a unref'ed timer leak
PR-URL: https://github.com/iojs/io.js/pull/1330 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-timers-unref-leak.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-timers-unref-leak.js b/test/parallel/test-timers-unref-leak.js
new file mode 100644
index 0000000000..c8f958a47c
--- /dev/null
+++ b/test/parallel/test-timers-unref-leak.js
@@ -0,0 +1,25 @@
+var assert = require('assert');
+
+var called = 0;
+var closed = 0;
+
+var timeout = setTimeout(function() {
+ called++;
+}, 10);
+timeout.unref();
+
+// Wrap `close` method to check if the handle was closed
+var close = timeout._handle.close;
+timeout._handle.close = function() {
+ closed++;
+ return close.apply(this, arguments);
+};
+
+// Just to keep process alive and let previous timer's handle die
+setTimeout(function() {
+}, 50);
+
+process.on('exit', function() {
+ assert.equal(called, 1);
+ assert.equal(closed, 1);
+});