Skip to content

Feature Request: Allow *run() generators? #106

@Zearin

Description

@Zearin

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions