diff options
author | Tobias Nießen <tniessen@tnie.de> | 2018-01-09 20:39:29 +0100 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2018-01-29 17:09:13 +0100 |
commit | 46e0a55b8492d15acf8cf4fcbcd3c8671e2e30f8 (patch) | |
tree | 994a868903f448abbfd4de91e15a01bcb561c387 /test/parallel/test-stream-transform-split-highwatermark.js | |
parent | e0864e50ecf917cbfa98d443e6f122425d6447cf (diff) | |
download | android-node-v8-46e0a55b8492d15acf8cf4fcbcd3c8671e2e30f8.tar.gz android-node-v8-46e0a55b8492d15acf8cf4fcbcd3c8671e2e30f8.tar.bz2 android-node-v8-46e0a55b8492d15acf8cf4fcbcd3c8671e2e30f8.zip |
stream: add type and range check for highWaterMark
The (h|readableH|writableH)ighWaterMark options should only permit
positive numbers and zero.
PR-URL: https://github.com/nodejs/node/pull/18098
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-transform-split-highwatermark.js')
-rw-r--r-- | test/parallel/test-stream-transform-split-highwatermark.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/test/parallel/test-stream-transform-split-highwatermark.js b/test/parallel/test-stream-transform-split-highwatermark.js index af2558ec6d..f931d4f6ce 100644 --- a/test/parallel/test-stream-transform-split-highwatermark.js +++ b/test/parallel/test-stream-transform-split-highwatermark.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const { Transform, Readable, Writable } = require('stream'); @@ -54,14 +54,33 @@ testTransform(0, 0, { writableHighWaterMark: 777, }); -// test undefined, null, NaN -[undefined, null, NaN].forEach((v) => { +// test undefined, null +[undefined, null].forEach((v) => { testTransform(DEFAULT, DEFAULT, { readableHighWaterMark: v }); testTransform(DEFAULT, DEFAULT, { writableHighWaterMark: v }); testTransform(666, DEFAULT, { highWaterMark: v, readableHighWaterMark: 666 }); testTransform(DEFAULT, 777, { highWaterMark: v, writableHighWaterMark: 777 }); }); +// test NaN +{ + common.expectsError(() => { + new Transform({ readableHighWaterMark: NaN }); + }, { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: 'The value "NaN" is invalid for option "readableHighWaterMark"' + }); + + common.expectsError(() => { + new Transform({ writableHighWaterMark: NaN }); + }, { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: 'The value "NaN" is invalid for option "writableHighWaterMark"' + }); +} + // test non Duplex streams ignore the options { const r = new Readable({ readableHighWaterMark: 666 }); |