@@ -20,9 +20,12 @@ const {
2020
2121// HighWaterMark must be integer >= 1
2222assert . throws ( ( ) => push ( { highWaterMark : 'bad' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
23- assert . throws ( ( ) => push ( { highWaterMark : 0 } ) , { code : 'ERR_OUT_OF_RANGE' } ) ;
24- assert . throws ( ( ) => push ( { highWaterMark : - 1 } ) , { code : 'ERR_OUT_OF_RANGE' } ) ;
2523assert . throws ( ( ) => push ( { highWaterMark : 1.5 } ) , { code : 'ERR_OUT_OF_RANGE' } ) ;
24+ // Values < 1 are clamped to 1
25+ push ( { highWaterMark : 0 } ) . writer . endSync ( ) ;
26+ push ( { highWaterMark : - 1 } ) . writer . endSync ( ) ;
27+ // Values above MAX_SAFE_INTEGER are clamped
28+ push ( { highWaterMark : Number . MAX_SAFE_INTEGER } ) . writer . endSync ( ) ;
2629
2730// Signal must be AbortSignal
2831assert . throws ( ( ) => push ( { signal : 'bad' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
@@ -80,7 +83,6 @@ assert.throws(() => pullSync(fromSync('a'), 42), { code: 'ERR_INVALID_ARG_TYPE'
8083// =============================================================================
8184
8285assert . throws ( ( ) => broadcast ( { highWaterMark : 'bad' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
83- assert . throws ( ( ) => broadcast ( { highWaterMark : 0 } ) , { code : 'ERR_OUT_OF_RANGE' } ) ;
8486assert . throws ( ( ) => broadcast ( { signal : { } } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
8587assert . throws ( ( ) => broadcast ( { backpressure : 'bad' } ) , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
8688
@@ -94,15 +96,12 @@ assert.throws(() => Broadcast.from('bad'), { code: 'ERR_INVALID_ARG_TYPE' });
9496
9597assert . throws ( ( ) => share ( 42 ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
9698assert . throws ( ( ) => share ( from ( 'a' ) , { highWaterMark : 'bad' } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
97- assert . throws ( ( ) => share ( from ( 'a' ) , { highWaterMark : 0 } ) , { code : 'ERR_OUT_OF_RANGE' } ) ;
9899assert . throws ( ( ) => share ( from ( 'a' ) , { signal : { } } ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
99100assert . throws ( ( ) => share ( from ( 'a' ) , { backpressure : 'bad' } ) , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
100101
101102assert . throws ( ( ) => shareSync ( 42 ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
102103assert . throws ( ( ) => shareSync ( fromSync ( 'a' ) , { highWaterMark : 'bad' } ) ,
103104 { code : 'ERR_INVALID_ARG_TYPE' } ) ;
104- assert . throws ( ( ) => shareSync ( fromSync ( 'a' ) , { highWaterMark : 0 } ) ,
105- { code : 'ERR_OUT_OF_RANGE' } ) ;
106105
107106// Share.from / SyncShare.fromSync reject non-iterable
108107assert . throws ( ( ) => Share . from ( 42 ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
0 commit comments