2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-12-24 01:02:12 +01:00
|
|
|
require('../common');
|
2016-12-31 00:38:06 +01:00
|
|
|
const assert = require('assert');
|
2015-02-03 02:12:41 +01:00
|
|
|
|
2016-12-31 00:38:06 +01:00
|
|
|
const Writable = require('stream').Writable;
|
2015-02-03 02:12:41 +01:00
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
let _writeCalled = false;
|
2015-02-03 02:12:41 +01:00
|
|
|
function _write(d, e, n) {
|
|
|
|
_writeCalled = true;
|
|
|
|
}
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const w = new Writable({ write: _write });
|
2016-01-26 00:00:06 +01:00
|
|
|
w.end(Buffer.from('blerg'));
|
2015-02-03 02:12:41 +01:00
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
let _writevCalled = false;
|
|
|
|
let dLength = 0;
|
2015-02-03 02:12:41 +01:00
|
|
|
function _writev(d, n) {
|
|
|
|
dLength = d.length;
|
|
|
|
_writevCalled = true;
|
|
|
|
}
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const w2 = new Writable({ writev: _writev });
|
2015-02-03 02:12:41 +01:00
|
|
|
w2.cork();
|
|
|
|
|
2016-01-26 00:00:06 +01:00
|
|
|
w2.write(Buffer.from('blerg'));
|
|
|
|
w2.write(Buffer.from('blerg'));
|
2015-02-03 02:12:41 +01:00
|
|
|
w2.end();
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
process.on('exit', function() {
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(w._write, _write);
|
2015-02-03 02:12:41 +01:00
|
|
|
assert(_writeCalled);
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual(w2._writev, _writev);
|
|
|
|
assert.strictEqual(dLength, 2);
|
2015-02-03 02:12:41 +01:00
|
|
|
assert(_writevCalled);
|
|
|
|
});
|