From cbba7dc52c232ecbfec1ec99ee04456f67fb32b9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Jun 2017 11:22:26 -0700 Subject: [PATCH 1/2] test: refactor domain tests * Check that noop callback is or isn't invoked as appropriate using common.mustCall() and common.mustNotCall() * Fix typo in array literal --- test/parallel/test-domain-crypto.js | 6 +++--- test/parallel/test-domain-timers.js | 2 +- test/parallel/test-domain.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index acc90a4a4868cf..d0bdbf4720b913 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -37,9 +37,9 @@ global.domain = require('domain'); // should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); -crypto.randomBytes(8, common.noop); +crypto.randomBytes(8, common.mustCall()); const buf = Buffer.alloc(8); crypto.randomFillSync(buf); crypto.pseudoRandomBytes(8); -crypto.pseudoRandomBytes(8, common.noop); -crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.noop); +crypto.pseudoRandomBytes(8, common.mustCall()); +crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.mustCall()); diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js index 888b452cb998b5..fe7247b2a92c95 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -51,4 +51,4 @@ immediated.run(function() { }); }); -const timeout = setTimeout(common.noop, 10 * 1000); +const timeout = setTimeout(common.mustNotCall(), 10 * 1000); diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index 1b6e1c7bbf4d02..fe0b7ca2be72f7 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -259,7 +259,7 @@ const fst = fs.createReadStream('stream for nonexistent file'); d.add(fst); expectCaught++; -[42, null, , false, common.noop, 'string'].forEach(function(something) { +[42, null, false, common.noop, 'string'].forEach(function(something) { const d = new domain.Domain(); d.run(function() { process.nextTick(function() { From fdf6669893357c06e6f18ba2a093f11b687712e2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Jun 2017 11:45:11 -0700 Subject: [PATCH 2/2] squash: nits per refack --- test/parallel/test-domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index fe0b7ca2be72f7..6cef4e52936c04 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -22,7 +22,7 @@ 'use strict'; // Simple tests of most basic domain functionality. -const common = require('../common'); +require('../common'); const assert = require('assert'); const domain = require('domain'); const events = require('events'); @@ -259,7 +259,7 @@ const fst = fs.createReadStream('stream for nonexistent file'); d.add(fst); expectCaught++; -[42, null, false, common.noop, 'string'].forEach(function(something) { +[42, null, undefined, false, () => {}, 'string'].forEach(function(something) { const d = new domain.Domain(); d.run(function() { process.nextTick(function() {