From f489a5234d0f5ccd1fa9c133a1909c6b0d89b6ad Mon Sep 17 00:00:00 2001
From: Matteo Rossi <teorossi82@yahoo.it>
Date: Mon, 14 Oct 2019 17:39:39 +0200
Subject: [PATCH 1/3] test: add cb error test for fs.close method

---
 test/parallel/test-fs-close-errors.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js
index 42d990410f9848..880f13b70bd18a 100644
--- a/test/parallel/test-fs-close-errors.js
+++ b/test/parallel/test-fs-close-errors.js
@@ -17,3 +17,14 @@ const fs = require('fs');
   assert.throws(() => fs.close(input), errObj);
   assert.throws(() => fs.closeSync(input), errObj);
 });
+
+// Test error when cb is not a function
+const fd = fs.openSync(__filename, 'r');
+
+['', false, null, {}, []].forEach((input) => {
+  const errObj = {
+    code: 'ERR_INVALID_CALLBACK',
+    name: 'TypeError'
+  };
+  assert.throws(() => fs.close(fd, input), errObj);
+});

From dcd979a88b8b2b5f03a678aa9eff56d13671d367 Mon Sep 17 00:00:00 2001
From: Matteo Rossi <teorossi82@yahoo.it>
Date: Tue, 15 Oct 2019 09:16:59 +0200
Subject: [PATCH 2/3] test: avoid block scope in cb error test for fs.close
 method

---
 test/parallel/test-fs-close-errors.js | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js
index 880f13b70bd18a..5d0c6a5dbcb7cb 100644
--- a/test/parallel/test-fs-close-errors.js
+++ b/test/parallel/test-fs-close-errors.js
@@ -18,13 +18,15 @@ const fs = require('fs');
   assert.throws(() => fs.closeSync(input), errObj);
 });
 
-// Test error when cb is not a function
-const fd = fs.openSync(__filename, 'r');
+{
+  // Test error when cb is not a function
+  const fd = fs.openSync(__filename, 'r');
 
-['', false, null, {}, []].forEach((input) => {
-  const errObj = {
-    code: 'ERR_INVALID_CALLBACK',
-    name: 'TypeError'
-  };
-  assert.throws(() => fs.close(fd, input), errObj);
-});
+  ['', false, null, {}, []].forEach((input) => {
+    const errObj = {
+      code: 'ERR_INVALID_CALLBACK',
+      name: 'TypeError'
+    };
+    assert.throws(() => fs.close(fd, input), errObj);
+  });
+}

From d31e2def3176779dfcbad821fdc8ec97bd48a07b Mon Sep 17 00:00:00 2001
From: Matteo Rossi <teorossi82@yahoo.it>
Date: Tue, 15 Oct 2019 09:42:12 +0200
Subject: [PATCH 3/3] test: added closeSync

---
 test/parallel/test-fs-close-errors.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js
index 5d0c6a5dbcb7cb..6168d5c20ab8e5 100644
--- a/test/parallel/test-fs-close-errors.js
+++ b/test/parallel/test-fs-close-errors.js
@@ -22,11 +22,14 @@ const fs = require('fs');
   // Test error when cb is not a function
   const fd = fs.openSync(__filename, 'r');
 
+  const errObj = {
+    code: 'ERR_INVALID_CALLBACK',
+    name: 'TypeError'
+  };
+
   ['', false, null, {}, []].forEach((input) => {
-    const errObj = {
-      code: 'ERR_INVALID_CALLBACK',
-      name: 'TypeError'
-    };
     assert.throws(() => fs.close(fd, input), errObj);
   });
+
+  fs.closeSync(fd);
 }