summaryrefslogtreecommitdiff
path: root/test/parallel/test-filehandle-close.js
blob: 457b06a486f90fbe946e69de3fd2035ea79d1144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');

// Test that using FileHandle.close to close an already-closed fd fails
// with EBADF.

(async function() {
  const fh = await fs.promises.open(__filename);
  fs.closeSync(fh.fd);

  assert.rejects(() => fh.close(), {
    code: 'EBADF',
    syscall: 'close'
  });
})().then(common.mustCall());