streams
streams copied to clipboard
Run ReadableStream tests against ReadableByteStream
At some point we probably want to figure out a way of running the ReadableStream tests against ReadableByteStream to cover their common surface area in terms of usage.
Will need to figure out some way of factoring out the creation logic, since that differs between each.
We might want to leave this for later when I am figuring out #216.
Is this issue obsoleted by e601d69f3ba40e6f4b5506e4bb1fbe3f3eabf393?
Maybe it should be renamed, but running the templated tests against a BYOB-mode stream is still a good idea.
I have a tentative plan for this:
- Move tests that are relevant to both types to a new directory, readable-streams-bikeshed. "relevant" usually means that the test result doesn't depend on the chunk type. For example, move the test
'ReadableStream instances should have the correct list of properties'from readable-stream/general.js to a new file named readable-streams-bikeshed/general.js. - Modify the moved tests to use Uint8Array chunks. Probably defining chunks named
aandbat the top of the file and replacing"a"witha, etc. would work in most cases. - Wrap all the tests in the file in a loop like
for (const type of [undefined, 'bytes']) - [optional] Check if readable-byte-streams/ contains duplicates of the copied tests and if so remove them.
This is important to make sure byte streams are rock-solid, but is a tremendous amount of work. Volunteers welcome.
That plan sounds great. An alternative to step 3 that might work nicely would be to wrap the test JS file into a function, e.g.
self.runReadableStreamTests = type => {
// ... lots of tests here
};
and then have two small wrapper test files. This would separate out the test results into two files which can be nicer for test expectation files etc.
So maybe something like
resources/common/foo.js: definitions of tests for the foo featurereadable-streams/common/foo.js: wrapper fortype: undefinedreadable-byte-streams/common/foo.js: wrapper fortype: 'bytes'
?