Skip to content

Commit a31f2f7

Browse files
committed
test: add implicit test for fs dispose handling with using
1 parent dcb9573 commit a31f2f7

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/parallel/test-fs-promises-file-handle-dispose.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,26 @@ async function explicitCall() {
2222
assert.throws(() => dhSync.readSync(), { code: 'ERR_DIR_CLOSED' });
2323
}
2424

25+
async function implicitCall() {
26+
{
27+
await using fh = await fs.open(__filename);
28+
fh.on('close', common.mustCall());
29+
}
30+
31+
let dh;
32+
{
33+
await using dirHandle = await fs.opendir(__dirname);
34+
dh = dirHandle;
35+
}
36+
await assert.rejects(dh.read(), { code: 'ERR_DIR_CLOSED' });
37+
38+
let dhSync;
39+
{
40+
using dirHandleSync = opendirSync(__dirname);
41+
dhSync = dirHandleSync;
42+
}
43+
assert.throws(() => dhSync.readSync(), { code: 'ERR_DIR_CLOSED' });
44+
}
45+
2546
explicitCall().then(common.mustCall());
26-
// TODO(aduh95): add test for implicit calls, with `await using` syntax.
47+
implicitCall().then(common.mustCall());

0 commit comments

Comments
 (0)