|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | +const fs = require('fs'); |
| 5 | + |
| 6 | +['', false, null, undefined, {}, []].forEach((i) => { |
| 7 | + common.expectsError( |
| 8 | + () => fs.fchown(i), |
| 9 | + { |
| 10 | + code: 'ERR_INVALID_ARG_TYPE', |
| 11 | + type: TypeError, |
| 12 | + message: 'The "fd" argument must be of type number' |
| 13 | + } |
| 14 | + ); |
| 15 | + common.expectsError( |
| 16 | + () => fs.fchownSync(i), |
| 17 | + { |
| 18 | + code: 'ERR_INVALID_ARG_TYPE', |
| 19 | + type: TypeError, |
| 20 | + message: 'The "fd" argument must be of type number' |
| 21 | + } |
| 22 | + ); |
| 23 | + |
| 24 | + common.expectsError( |
| 25 | + () => fs.fchown(1, i), |
| 26 | + { |
| 27 | + code: 'ERR_INVALID_ARG_TYPE', |
| 28 | + type: TypeError, |
| 29 | + message: 'The "uid" argument must be of type number' |
| 30 | + } |
| 31 | + ); |
| 32 | + common.expectsError( |
| 33 | + () => fs.fchownSync(1, i), |
| 34 | + { |
| 35 | + code: 'ERR_INVALID_ARG_TYPE', |
| 36 | + type: TypeError, |
| 37 | + message: 'The "uid" argument must be of type number' |
| 38 | + } |
| 39 | + ); |
| 40 | + |
| 41 | + common.expectsError( |
| 42 | + () => fs.fchown(1, 1, i), |
| 43 | + { |
| 44 | + code: 'ERR_INVALID_ARG_TYPE', |
| 45 | + type: TypeError, |
| 46 | + message: 'The "gid" argument must be of type number' |
| 47 | + } |
| 48 | + ); |
| 49 | + common.expectsError( |
| 50 | + () => fs.fchownSync(1, 1, i), |
| 51 | + { |
| 52 | + code: 'ERR_INVALID_ARG_TYPE', |
| 53 | + type: TypeError, |
| 54 | + message: 'The "gid" argument must be of type number' |
| 55 | + } |
| 56 | + ); |
| 57 | +}); |
| 58 | + |
| 59 | +[-1, 0xFFFFFFFF + 1].forEach((i) => { |
| 60 | + common.expectsError( |
| 61 | + () => fs.fchown(i), |
| 62 | + { |
| 63 | + code: 'ERR_OUT_OF_RANGE', |
| 64 | + type: RangeError, |
| 65 | + message: 'The "fd" argument is out of range' |
| 66 | + } |
| 67 | + ); |
| 68 | + common.expectsError( |
| 69 | + () => fs.fchownSync(i), |
| 70 | + { |
| 71 | + code: 'ERR_OUT_OF_RANGE', |
| 72 | + type: RangeError, |
| 73 | + message: 'The "fd" argument is out of range' |
| 74 | + } |
| 75 | + ); |
| 76 | +}); |
| 77 | + |
| 78 | +common.expectsError( |
| 79 | + () => fs.fchown(1, -1), |
| 80 | + { |
| 81 | + code: 'ERR_OUT_OF_RANGE', |
| 82 | + type: RangeError, |
| 83 | + message: 'The "uid" argument is out of range' |
| 84 | + } |
| 85 | +); |
| 86 | +common.expectsError( |
| 87 | + () => fs.fchownSync(1, -1), |
| 88 | + { |
| 89 | + code: 'ERR_OUT_OF_RANGE', |
| 90 | + type: RangeError, |
| 91 | + message: 'The "uid" argument is out of range' |
| 92 | + } |
| 93 | +); |
| 94 | + |
| 95 | +common.expectsError( |
| 96 | + () => fs.fchown(1, 1, -1), |
| 97 | + { |
| 98 | + code: 'ERR_OUT_OF_RANGE', |
| 99 | + type: RangeError, |
| 100 | + message: 'The "gid" argument is out of range' |
| 101 | + } |
| 102 | +); |
| 103 | +common.expectsError( |
| 104 | + () => fs.fchownSync(1, 1, -1), |
| 105 | + { |
| 106 | + code: 'ERR_OUT_OF_RANGE', |
| 107 | + type: RangeError, |
| 108 | + message: 'The "gid" argument is out of range' |
| 109 | + } |
| 110 | +); |
0 commit comments