From fe7ef1ad11b10ebb35f1b796c80ddc2a7abdfb76 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Tue, 6 Nov 2018 20:42:37 +0900 Subject: [PATCH] test: add test for autoDestroy in stream PR-URL: https://github.com/nodejs/node/pull/24127 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Mathias Buus --- test/parallel/test-stream-auto-destroy.js | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/parallel/test-stream-auto-destroy.js b/test/parallel/test-stream-auto-destroy.js index 7bce8a56368313..2a1a5190debb57 100644 --- a/test/parallel/test-stream-auto-destroy.js +++ b/test/parallel/test-stream-auto-destroy.js @@ -82,3 +82,31 @@ const assert = require('assert'); assert(finished); })); } + +{ + const r = new stream.Readable({ + read() { + r2.emit('error', new Error('fail')); + } + }); + const r2 = new stream.Readable({ + autoDestroy: true, + destroy: common.mustCall((err, cb) => cb()) + }); + + r.pipe(r2); +} + +{ + const r = new stream.Readable({ + read() { + w.emit('error', new Error('fail')); + } + }); + const w = new stream.Writable({ + autoDestroy: true, + destroy: common.mustCall((err, cb) => cb()) + }); + + r.pipe(w); +}