summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-chmod.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-11-26 14:27:15 -0800
committerJames M Snell <jasnell@gmail.com>2017-12-13 13:26:43 -0800
commit0a01aa8e946ee86199af56ff3eac9bae67235ca8 (patch)
tree59deb581980110b89fa22897b81e9a8bdd7c6ebe /test/parallel/test-fs-chmod.js
parentd453fac33b0769a12b8b926f0d77e1bbd834b397 (diff)
downloadandroid-node-v8-0a01aa8e946ee86199af56ff3eac9bae67235ca8.tar.gz
android-node-v8-0a01aa8e946ee86199af56ff3eac9bae67235ca8.tar.bz2
android-node-v8-0a01aa8e946ee86199af56ff3eac9bae67235ca8.zip
fs: move type checking for fs.fchmod 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-chmod.js')
-rw-r--r--test/parallel/test-fs-chmod.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js
index 7d4b7a10db..9eae75c3c7 100644
--- a/test/parallel/test-fs-chmod.js
+++ b/test/parallel/test-fs-chmod.js
@@ -108,6 +108,15 @@ fs.open(file2, 'w', common.mustCall((err, fd) => {
assert.strictEqual(mode_async, fs.fstatSync(fd).mode & 0o777);
}
+ common.expectsError(
+ () => fs.fchmod(fd, {}),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "mode" argument must be of type number'
+ }
+ );
+
fs.fchmodSync(fd, mode_sync);
if (common.isWindows) {
assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync);
@@ -136,6 +145,43 @@ if (fs.lchmod) {
}));
}
+['', false, null, undefined, {}, []].forEach((i) => {
+ common.expectsError(
+ () => fs.fchmod(i, 0o000),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "fd" argument must be of type number'
+ }
+ );
+ common.expectsError(
+ () => fs.fchmodSync(i, 0o000),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "fd" argument must be of type number'
+ }
+ );
+});
+
+[-1, 0xFFFFFFFF + 1].forEach((i) => {
+ common.expectsError(
+ () => fs.fchmod(i, 0o000),
+ {
+ code: 'ERR_OUT_OF_RANGE',
+ type: RangeError,
+ message: 'The "fd" argument is out of range'
+ }
+ );
+ common.expectsError(
+ () => fs.fchmodSync(i, 0o000),
+ {
+ code: 'ERR_OUT_OF_RANGE',
+ type: RangeError,
+ message: 'The "fd" argument is out of range'
+ }
+ );
+});
process.on('exit', function() {
assert.strictEqual(0, openCount);