2017-01-20 15:33:09 +09:00
|
|
|
'use strict';
|
2017-03-24 09:46:44 -07:00
|
|
|
const common = require('../common');
|
2023-03-03 16:55:58 +09:00
|
|
|
const assert = require('node:assert');
|
|
|
|
const fs = require('node:fs');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
2017-01-20 15:33:09 +09:00
|
|
|
|
2023-08-15 22:45:24 +09:00
|
|
|
const testPath = tmpdir.resolve('assert-encoding-error');
|
2017-01-20 15:33:09 +09:00
|
|
|
const options = 'test';
|
2019-12-25 18:02:16 +01:00
|
|
|
const expectedError = {
|
2020-08-08 19:01:59 +03:00
|
|
|
code: 'ERR_INVALID_ARG_VALUE',
|
2019-12-25 18:02:16 +01:00
|
|
|
name: 'TypeError',
|
|
|
|
};
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readFile(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readFileSync(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readdir(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readdirSync(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readlink(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.readlinkSync(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.writeFile(testPath, 'data', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.writeFileSync(testPath, 'data', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.appendFile(testPath, 'data', options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.appendFileSync(testPath, 'data', options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.watch(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.realpath(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.realpathSync(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.mkdtemp(testPath, options, common.mustNotCall());
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.mkdtempSync(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.ReadStream(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|
2017-01-20 15:33:09 +09:00
|
|
|
|
|
|
|
assert.throws(() => {
|
2023-03-03 16:55:58 +09:00
|
|
|
fs.WriteStream(testPath, options);
|
2017-02-11 23:25:33 -02:00
|
|
|
}, expectedError);
|