@@ -108,6 +108,15 @@ fs.open(file2, 'w', common.mustCall((err, fd) => {
108
108
assert . strictEqual ( mode_async , fs . fstatSync ( fd ) . mode & 0o777 ) ;
109
109
}
110
110
111
+ common . expectsError (
112
+ ( ) => fs . fchmod ( fd , { } ) ,
113
+ {
114
+ code : 'ERR_INVALID_ARG_TYPE' ,
115
+ type : TypeError ,
116
+ message : 'The "mode" argument must be of type number'
117
+ }
118
+ ) ;
119
+
111
120
fs . fchmodSync ( fd , mode_sync ) ;
112
121
if ( common . isWindows ) {
113
122
assert . ok ( ( fs . fstatSync ( fd ) . mode & 0o777 ) & mode_sync ) ;
@@ -136,6 +145,43 @@ if (fs.lchmod) {
136
145
} ) ) ;
137
146
}
138
147
148
+ [ '' , false , null , undefined , { } , [ ] ] . forEach ( ( i ) => {
149
+ common . expectsError (
150
+ ( ) => fs . fchmod ( i , 0o000 ) ,
151
+ {
152
+ code : 'ERR_INVALID_ARG_TYPE' ,
153
+ type : TypeError ,
154
+ message : 'The "fd" argument must be of type number'
155
+ }
156
+ ) ;
157
+ common . expectsError (
158
+ ( ) => fs . fchmodSync ( i , 0o000 ) ,
159
+ {
160
+ code : 'ERR_INVALID_ARG_TYPE' ,
161
+ type : TypeError ,
162
+ message : 'The "fd" argument must be of type number'
163
+ }
164
+ ) ;
165
+ } ) ;
166
+
167
+ [ - 1 , 0xFFFFFFFF + 1 ] . forEach ( ( i ) => {
168
+ common . expectsError (
169
+ ( ) => fs . fchmod ( i , 0o000 ) ,
170
+ {
171
+ code : 'ERR_OUT_OF_RANGE' ,
172
+ type : RangeError ,
173
+ message : 'The "fd" argument is out of range'
174
+ }
175
+ ) ;
176
+ common . expectsError (
177
+ ( ) => fs . fchmodSync ( i , 0o000 ) ,
178
+ {
179
+ code : 'ERR_OUT_OF_RANGE' ,
180
+ type : RangeError ,
181
+ message : 'The "fd" argument is out of range'
182
+ }
183
+ ) ;
184
+ } ) ;
139
185
140
186
process . on ( 'exit' , function ( ) {
141
187
assert . strictEqual ( 0 , openCount ) ;
0 commit comments