2017-01-20 15:33:09 +09:00
|
|
|
'use strict';
|
2017-03-24 09:46:44 -07:00
|
|
|
const common = require('../common');
|
2017-01-20 15:33:09 +09:00
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const options = 'test';
|
2019-12-25 18:02:16 +01:00
|
|
|
const expectedError = {
|
2017-02-11 23:25:33 -02:00
|
|
|
code: 'ERR_INVALID_OPT_VALUE_ENCODING',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError',
|
|
|
|
};
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.readFile('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.readFileSync('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.readdir('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.readdirSync('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.readlink('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.readlinkSync('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.writeFile('path', 'data', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.writeFileSync('path', 'data', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.appendFile('path', 'data', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.appendFileSync('path', 'data', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.watch('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.realpath('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.realpathSync('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2017-05-25 14:47:52 -07:00
|
|
|
fs.mkdtemp('path', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.mkdtempSync('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.ReadStream('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
fs.WriteStream('path', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|