1'use strict'; 2 3const common = require('../common'); 4 5const assert = require('assert'); 6const stream = require('stream'); 7 8const writable = new stream.Writable(); 9 10writable._write = (chunk, encoding, cb) => { 11 assert.strictEqual(writable._writableState.ended, false); 12 assert.strictEqual(writable._writableState.writable, undefined); 13 assert.strictEqual(writable.writableEnded, false); 14 cb(); 15}; 16 17assert.strictEqual(writable._writableState.ended, false); 18assert.strictEqual(writable._writableState.writable, undefined); 19assert.strictEqual(writable.writable, true); 20assert.strictEqual(writable.writableEnded, false); 21 22writable.end('testing ended state', common.mustCall(() => { 23 assert.strictEqual(writable._writableState.ended, true); 24 assert.strictEqual(writable._writableState.writable, undefined); 25 assert.strictEqual(writable.writable, false); 26 assert.strictEqual(writable.writableEnded, true); 27})); 28 29assert.strictEqual(writable._writableState.ended, true); 30assert.strictEqual(writable._writableState.writable, undefined); 31assert.strictEqual(writable.writable, false); 32assert.strictEqual(writable.writableEnded, true); 33