test: fix this scope bug in test-stream2-writable.js

PR-URL: https://github.com/nodejs/node/pull/27111
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
gengjiawen 2019-04-06 11:01:23 +08:00 committed by ZYSzys
parent 0a25ace9c3
commit 93df085386

View File

@ -322,13 +322,14 @@ for (let i = 0; i < chunks.length; i++) {
assert.strictEqual(this.writing, undefined);
wrote = true;
this.writing = true;
setTimeout(function() {
setTimeout(() => {
this.writing = false;
cb();
}, 1);
};
w.on('finish', common.mustCall(function() {
assert.strictEqual(wrote, true);
assert.strictEqual(this.writing, false);
}));
w.write(Buffer.alloc(0));
w.end();