@@ -35,30 +35,25 @@ fs.open(filepath, 'r', common.mustSucceed((fd) => {
3535 } ) ) ;
3636} ) ) ;
3737
38- let filehandle = null ;
39-
4038// Tests for promises api
4139( async ( ) => {
42- filehandle = await fsPromises . open ( filepath , 'r' ) ;
40+ await using filehandle = await fsPromises . open ( filepath , 'r' ) ;
4341 const readObject = await filehandle . read ( buf , { offset : null } ) ;
4442 assert . strictEqual ( readObject . buffer [ 0 ] , 120 ) ;
4543} ) ( )
46- . finally ( ( ) => filehandle ?. close ( ) )
4744. then ( common . mustCall ( ) ) ;
4845
4946// Undocumented: omitted position works the same as position === null
5047( async ( ) => {
51- filehandle = await fsPromises . open ( filepath , 'r' ) ;
48+ await using filehandle = await fsPromises . open ( filepath , 'r' ) ;
5249 const readObject = await filehandle . read ( buf , null , buf . length ) ;
5350 assert . strictEqual ( readObject . buffer [ 0 ] , 120 ) ;
5451} ) ( )
55- . finally ( ( ) => filehandle ?. close ( ) )
5652. then ( common . mustCall ( ) ) ;
5753
5854( async ( ) => {
59- filehandle = await fsPromises . open ( filepath , 'r' ) ;
55+ await using filehandle = await fsPromises . open ( filepath , 'r' ) ;
6056 const readObject = await filehandle . read ( buf , null , buf . length , 0 ) ;
6157 assert . strictEqual ( readObject . buffer [ 0 ] , 120 ) ;
6258} ) ( )
63- . finally ( ( ) => filehandle ?. close ( ) )
6459. then ( common . mustCall ( ) ) ;
0 commit comments