mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
825 B
34 lines
825 B
'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);
|
|
|