diff options
author | James M Snell <jasnell@gmail.com> | 2017-11-26 12:44:20 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-12-13 13:26:21 -0800 |
commit | 8974df15a973e97a74cf9fb0ccb45c11baa7b54a (patch) | |
tree | cf2f1e2cd246d8b555d6ea172f42d51b7f465592 /test/parallel/test-fs-close-errors.js | |
parent | 04ae4862e670a8849454e6d8db4d8f73d0492190 (diff) | |
download | android-node-v8-8974df15a973e97a74cf9fb0ccb45c11baa7b54a.tar.gz android-node-v8-8974df15a973e97a74cf9fb0ccb45c11baa7b54a.tar.bz2 android-node-v8-8974df15a973e97a74cf9fb0ccb45c11baa7b54a.zip |
fs: move type checking for fs.close to js
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/parallel/test-fs-close-errors.js')
-rw-r--r-- | test/parallel/test-fs-close-errors.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js new file mode 100644 index 0000000000..040f6def44 --- /dev/null +++ b/test/parallel/test-fs-close-errors.js @@ -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' + } + ); +}); |