@@ -179,6 +179,16 @@ function testFtruncate(cb) {
|
179 | 179 | process.on('exit', () => fs.closeSync(fd)); |
180 | 180 | |
181 | 181 | ['', false, null, {}, []].forEach((input) => { |
| 182 | +assert.throws( |
| 183 | +() => fs.truncate(file5, input, common.mustNotCall()), |
| 184 | +{ |
| 185 | +code: 'ERR_INVALID_ARG_TYPE', |
| 186 | +name: 'TypeError [ERR_INVALID_ARG_TYPE]', |
| 187 | +message: 'The "len" argument must be of type number. ' + |
| 188 | +`Received type ${typeof input}` |
| 189 | +} |
| 190 | +); |
| 191 | + |
182 | 192 | assert.throws( |
183 | 193 | () => fs.ftruncate(fd, input), |
184 | 194 | { |
@@ -191,6 +201,16 @@ function testFtruncate(cb) {
|
191 | 201 | }); |
192 | 202 | |
193 | 203 | [-1.5, 1.5].forEach((input) => { |
| 204 | +assert.throws( |
| 205 | +() => fs.truncate(file5, input), |
| 206 | +{ |
| 207 | +code: 'ERR_OUT_OF_RANGE', |
| 208 | +name: 'RangeError [ERR_OUT_OF_RANGE]', |
| 209 | +message: 'The value of "len" is out of range. It must be ' + |
| 210 | +`an integer. Received ${input}` |
| 211 | +} |
| 212 | +); |
| 213 | + |
194 | 214 | assert.throws( |
195 | 215 | () => fs.ftruncate(fd, input), |
196 | 216 | { |
|