blob: 6f74ca08d2366d5d3f146028629371651fae767e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
'use strict';
const common = require('../common');
const assert = require('assert');
const stream = require('stream');
// ensure consistency between the finish event when using cork()
// and writev and when not using them
{
const writable = new stream.Writable();
writable._write = (chunks, encoding, cb) => {
cb(new Error('write test error'));
};
writable.on('finish', common.mustCall());
writable.on('prefinish', common.mustCall());
writable.on('error', common.mustCall((er) => {
assert.strictEqual(er.message, 'write test error');
}));
writable.end('test');
}
{
const writable = new stream.Writable();
writable._write = (chunks, encoding, cb) => {
cb(new Error('write test error'));
};
writable._writev = (chunks, cb) => {
cb(new Error('writev test error'));
};
writable.on('finish', common.mustCall());
writable.on('prefinish', common.mustCall());
writable.on('error', common.mustCall((er) => {
assert.strictEqual(er.message, 'writev test error');
}));
writable.cork();
writable.write('test');
setImmediate(function() {
writable.end('test');
});
}
|