Skip to content

Commit

Permalink
Test whether array.push() works while reading
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Jan 13, 2022
1 parent 7e2e6a2 commit ea4ec04
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions streams/readable-streams/from.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,26 @@ promise_test(async t => {
await reader.closed;

}, `ReadableStream.from: reader.cancel() inside return()`);

promise_test(async t => {

let array = ['a', 'b'];

const rs = ReadableStream.from(array);
const reader = rs.getReader();

const read1 = await reader.read();
assert_object_equals(read1, { value: 'a', done: false }, 'first read should be correct');
const read2 = await reader.read();
assert_object_equals(read2, { value: 'b', done: false }, 'second read should be correct');

array.push('c');

const read3 = await reader.read();
assert_object_equals(read3, { value: 'c', done: false }, 'third read after push() should be correct');
const read4 = await reader.read();
assert_object_equals(read4, { value: undefined, done: true }, 'fourth read should be done');

await reader.closed;

}, `ReadableStream.from(array), push() to array while reading`);

0 comments on commit ea4ec04

Please sign in to comment.