1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5const stream = require('stream');
6let shutdown = false;
7
8const w = new stream.Writable({
9  final: common.mustCall(function(cb) {
10    assert.strictEqual(this, w);
11    setTimeout(function() {
12      shutdown = true;
13      cb();
14    }, 100);
15  }),
16  write: function(chunk, e, cb) {
17    process.nextTick(cb);
18  }
19});
20w.on('finish', common.mustCall(function() {
21  assert(shutdown);
22}));
23w.write(Buffer.allocUnsafe(1));
24w.end(Buffer.allocUnsafe(0));
25