Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
youennf authored Aug 3, 2021
1 parent dfa0509 commit 3ed7db2
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions streams/piping/pipe-through.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,66 @@ test(() => {
}
}), 'pipeThrough should throw');
}, 'pipeThrough() should throw if an option getter grabs a writer');

test(() => {
const rs = new ReadableStream();
const readable = new ReadableStream();
const writable = new WritableStream();
rs.pipeThrough({readable, writable}, null);
}, 'pipeThrough() should not throw if option is null');

test(() => {
const rs = new ReadableStream();
const readable = new ReadableStream();
const writable = new WritableStream();
rs.pipeThrough({readable, writable}, {signal:undefined});
}, 'pipeThrough() should not throw if signal is undefined');

function tryPipeThrough(pair, options)
{
const rs = new ReadableStream();
if (!pair)
pair = {readable:new ReadableStream(), writable:new WritableStream()};
try {
rs.pipeThrough(pair, options)
} catch (e) {
return e;
}
}

test(() => {
let result = tryPipeThrough({
get readable() {
return new ReadableStream();
},
get writable() {
throw "writable threw";
}
}, { });
assert_equals(result, "writable threw");

result = tryPipeThrough({
get readable() {
throw "readable threw";
},
get writable() {
throw "writable threw";
}
}, { });
assert_equals(result, "readable threw");

result = tryPipeThrough({
get readable() {
throw "readable threw";
},
get writable() {
throw "writable threw";
}
}, {
get preventAbort() {
throw "preventAbort threw";
}
});
assert_equals(result, "readable threw");

}, 'pipeThrough() should throw if readable/writable getters throw');

0 comments on commit 3ed7db2

Please sign in to comment.