diff options
author | Rich Trott <rtrott@gmail.com> | 2016-11-06 20:01:17 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-11-09 19:21:30 -0800 |
commit | 837e82299288e66300c318fc7567cb0bd022666d (patch) | |
tree | 753bab0576478aa46ba694529751822b706f77a5 /test/addons | |
parent | ef6a5cf40a7fe7f68fe85e1528970f351e31ed13 (diff) | |
download | android-node-v8-837e82299288e66300c318fc7567cb0bd022666d.tar.gz android-node-v8-837e82299288e66300c318fc7567cb0bd022666d.tar.bz2 android-node-v8-837e82299288e66300c318fc7567cb0bd022666d.zip |
test: refactor make-callback-recurse test
Move copy/pasted callback into its own function.
PR-URL: https://github.com/nodejs/node/pull/9498
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test/addons')
-rw-r--r-- | test/addons/make-callback-recurse/test.js | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js index 67cc479c5a..0145a142e4 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), 3); + setImmediate(common.mustCall(testTimer), 2); + setTimeout(common.mustCall(testTimer), 1, 1); } |