diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-07-16 00:03:23 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-16 21:33:53 -0700 |
commit | 4a2bd69db99c1bb8692e1f653edcb225fbc23032 (patch) | |
tree | b90971ab2b513dcf3f69758113d72661ea017e16 /test/parallel/test-stream-readable-invalid-chunk.js | |
parent | a890771cd0a31bda055fc71741ace7822bc678dd (diff) | |
download | android-node-v8-4a2bd69db99c1bb8692e1f653edcb225fbc23032.tar.gz android-node-v8-4a2bd69db99c1bb8692e1f653edcb225fbc23032.tar.bz2 android-node-v8-4a2bd69db99c1bb8692e1f653edcb225fbc23032.zip |
stream: fix destroy() behavior
Ensure errorEmitted is always set. Only emit 'error' once.
PR-URL: https://github.com/nodejs/node/pull/29058
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-readable-invalid-chunk.js')
-rw-r--r-- | test/parallel/test-stream-readable-invalid-chunk.js | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/test/parallel/test-stream-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js index fcd7414bb6..3e147c065f 100644 --- a/test/parallel/test-stream-readable-invalid-chunk.js +++ b/test/parallel/test-stream-readable-invalid-chunk.js @@ -3,17 +3,32 @@ const common = require('../common'); const stream = require('stream'); -const readable = new stream.Readable({ - read: () => {} -}); - -function checkError(fn) { - common.expectsError(fn, { +function testPushArg(val) { + const readable = new stream.Readable({ + read: () => {} + }); + readable.on('error', common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError + })); + readable.push(val); +} + +testPushArg([]); +testPushArg({}); +testPushArg(0); + +function testUnshiftArg(val) { + const readable = new stream.Readable({ + read: () => {} }); + readable.on('error', common.expectsError({ + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + })); + readable.unshift(val); } -checkError(() => readable.push([])); -checkError(() => readable.push({})); -checkError(() => readable.push(0)); +testUnshiftArg([]); +testUnshiftArg({}); +testUnshiftArg(0); |