-
Notifications
You must be signed in to change notification settings - Fork 4
Description
From my journey learning to use hTest in #100, I’m trying to convert some pretty basic Web Platform Tests into hTest in order to learn how to write things hTest-style.
Although the flexibility of the test syntax means there’s probably an alternative way to write this, what my brain wants to do is something like this:
// …
{
data: {
constructors: [ DOMRect, DOMRectReadOnly ]
},
*run(...args) {
for (const ctr of this.data.constructors) {
yield new ctr(...args)
}
},
tests: [ … ]
}I know that as soon as async arrived, everyone wanted to ditch generators and make everything async.
Although I haven’t personally written an async generator, Dr. Axel’s (of 2ality fame) chapter on Async Iteration from Exploring Javascript makes it clear that generators and async are orthogonal.
That makes sense to me, so even without firsthand experience (beyond surface level), my brain likes to keep the concepts separate, rather than overwriting all generators with async functions.
✅ hTest already has async support out of the box.
❓ Is it feasible to allow generators for run() functions, too?