mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
22 lines
578 B
JavaScript
22 lines
578 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const filepath = path.join(common.fixturesDir, 'x.txt');
|
|
const fd = fs.openSync(filepath, 'r');
|
|
const expected = 'xyz\n';
|
|
|
|
// Error must be thrown with string
|
|
assert.throws(() => {
|
|
fs.read(fd,
|
|
expected.length,
|
|
0,
|
|
'utf-8',
|
|
common.noop);
|
|
}, /Second argument needs to be a buffer/);
|
|
|
|
assert.throws(() => {
|
|
fs.readSync(fd, expected.length, 0, 'utf-8');
|
|
}, /Second argument needs to be a buffer/);
|