mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
690bdede13
Currently, make lint is failing with the following error: 3:7 error 'common' is assigned a value but never used no-unused-vars ✖ 1 problem (1 error, 0 warnings) PR-URL: https://github.com/nodejs/node/pull/9334 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
35 lines
825 B
JavaScript
35 lines
825 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
const stream = require('stream');
|
|
|
|
const writable = new stream.Writable();
|
|
|
|
function testStates(ending, finished, ended) {
|
|
assert.strictEqual(writable._writableState.ending, ending);
|
|
assert.strictEqual(writable._writableState.finished, finished);
|
|
assert.strictEqual(writable._writableState.ended, ended);
|
|
}
|
|
|
|
writable._write = (chunk, encoding, cb) => {
|
|
// ending, finished, ended start in false.
|
|
testStates(false, false, false);
|
|
cb();
|
|
};
|
|
|
|
writable.on('finish', () => {
|
|
// ending, finished, ended = true.
|
|
testStates(true, true, true);
|
|
});
|
|
|
|
writable.end('testing function end()', () => {
|
|
// ending, finished, ended = true.
|
|
testStates(true, true, true);
|
|
});
|
|
|
|
// ending, ended = true.
|
|
// finished = false.
|
|
testStates(true, false, true);
|