From f474277bca103257f32d884548dd53db1af49875 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 6 Nov 2016 20:01:17 -0800 Subject: [PATCH 1/2] test: refactor make-callback-recurse test Move copy/pasted callback into its own function. --- test/addons/make-callback-recurse/test.js | 36 ++++++----------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js index 67cc479c5af474..41d4bf4f3795c0 100644 --- a/test/addons/make-callback-recurse/test.js +++ b/test/addons/make-callback-recurse/test.js @@ -132,38 +132,20 @@ function checkDomains() { })); }), 1); - // Make sure nextTick, setImmediate and setTimeout can all recover properly - // after a thrown makeCallback call. - process.nextTick(common.mustCall(function() { + function testTimer(id) { + // Make sure nextTick, setImmediate and setTimeout can all recover properly + // after a thrown makeCallback call. const d = domain.create(); d.on('error', common.mustCall(function(e) { - assert.strictEqual(e.message, 'throw from domain 3'); + assert.strictEqual(e.message, `throw from domain ${id}`); })); makeCallback({domain: d}, function() { - throw new Error('throw from domain 3'); + throw new Error(`throw from domain ${id}`); }); throw new Error('UNREACHABLE'); - })); + } - setImmediate(common.mustCall(function() { - const d = domain.create(); - d.on('error', common.mustCall(function(e) { - assert.strictEqual(e.message, 'throw from domain 2'); - })); - makeCallback({domain: d}, function() { - throw new Error('throw from domain 2'); - }); - throw new Error('UNREACHABLE'); - })); - - setTimeout(common.mustCall(function() { - const d = domain.create(); - d.on('error', common.mustCall(function(e) { - assert.strictEqual(e.message, 'throw from domain 1'); - })); - makeCallback({domain: d}, function() { - throw new Error('throw from domain 1'); - }); - throw new Error('UNREACHABLE'); - })); + process.nextTick(common.mustCall(testTimer.bind(null, 3))); + setImmediate(common.mustCall(testTimer.bind(null, 2))); + setTimeout(common.mustCall(testTimer.bind(null, 1)), 1); } From 22d6c5d2fe62f9e3af359b2b964e60226cb89e68 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 6 Nov 2016 20:44:46 -0800 Subject: [PATCH 2/2] squash: no bind --- test/addons/make-callback-recurse/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js index 41d4bf4f3795c0..0145a142e40f09 100644 --- a/test/addons/make-callback-recurse/test.js +++ b/test/addons/make-callback-recurse/test.js @@ -145,7 +145,7 @@ function checkDomains() { throw new Error('UNREACHABLE'); } - process.nextTick(common.mustCall(testTimer.bind(null, 3))); - setImmediate(common.mustCall(testTimer.bind(null, 2))); - setTimeout(common.mustCall(testTimer.bind(null, 1)), 1); + process.nextTick(common.mustCall(testTimer), 3); + setImmediate(common.mustCall(testTimer), 2); + setTimeout(common.mustCall(testTimer), 1, 1); }