nodejs-mozilla/test/parallel/test-filehandle-close.js

18 lines
406 B
JavaScript
Raw Normal View History

2022-07-18 11:52:00 +08:00
'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());