Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2939950

Browse filesBrowse files
IlyasShabiaduh95
authored andcommitted
test: add implicit test for fs dispose handling with using
PR-URL: #61140 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 4bbbe75 commit 2939950
Copy full SHA for 2939950

1 file changed

+25-1Lines changed: 25 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-promises-file-handle-dispose.js
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,29 @@ async function explicitCall() {
2222
assert.throws(() => dhSync.readSync(), { code: 'ERR_DIR_CLOSED' });
2323
}
2424

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.