Add tests for ReadableStream.from()#27009
Add tests for ReadableStream.from()#27009MattiasBuelens merged 20 commits intoweb-platform-tests:masterfrom
Conversation
50b37b0 to
549093b
Compare
ricea
left a comment
There was a problem hiding this comment.
lgtm
Let's have tests for three horrible re-entrant cases:
reader.read()is called insidenext().reader.cancel()is called insidenext().reader.cancel()is called insidereturn().
|
@ricea Great ideas! I've added tests for What would you want to see from a " If you mean let reader;
const iterable = {
async next() {
return await reader.read();
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // stalls foreverIf you mean calling let reader;
const iterable = {
async next() {
reader.read(); // calls next() again, which calls read() again, repeating forever
return { value: 'a', done: false };
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // blows up the microtask queueOr do we only want to call let nextCalls = 0;
let reader;
const iterable = {
async next() {
nextCalls += 1;
if (nextCalls === 1) {
reader.read();
}
return { value: 'a', done: false };
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // calls next() twice
await reader.read(); // calls next() once |
|
New tests lgtm.
Yes. Calling it once should be sufficient to find any reentrancy bugs. |
602d2c2 to
8777511
Compare
8777511 to
43497da
Compare
0fcecbf to
67fb793
Compare
67fb793 to
ea4ec04
Compare
|
@MattiasBuelens, can we merge the WPT tests? |
|
@youennf Yep, this is ready to go! |
Add tests for the new static method
ReadableStream.from().See whatwg/streams#1083 for the accompanying spec change.