-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: move type checking for fs.close to js
PR-URL: #17334 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
3 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const fs = require('fs'); | ||
|
||
['', false, null, undefined, {}, []].forEach((i) => { | ||
common.expectsError( | ||
() => fs.close(i), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: 'The "fd" argument must be of type number' | ||
} | ||
); | ||
common.expectsError( | ||
() => fs.closeSync(i), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: 'The "fd" argument must be of type number' | ||
} | ||
); | ||
}); | ||
|
||
[-1, 0xFFFFFFFF + 1].forEach((i) => { | ||
common.expectsError( | ||
() => fs.close(i), | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
type: RangeError, | ||
message: 'The "fd" argument is out of range' | ||
} | ||
); | ||
common.expectsError( | ||
() => fs.closeSync(i), | ||
{ | ||
code: 'ERR_OUT_OF_RANGE', | ||
type: RangeError, | ||
message: 'The "fd" argument is out of range' | ||
} | ||
); | ||
}); |