Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical way to share generators #33

Open
ComradeVanti opened this issue Nov 15, 2024 · 0 comments
Open

Canonical way to share generators #33

ComradeVanti opened this issue Nov 15, 2024 · 0 comments

Comments

@ComradeVanti
Copy link

ComradeVanti commented Nov 15, 2024

Say I develop a package which provides a type Angle. As part of my test suite for my package I have created generators for this type like

extension AnyAngle on Any {
  /// Generates a [Angle] in a certain range.
  Generator<Angle> angleInRange(double min, double max) {
    assert(min >= -180);
    assert(min < max);
    assert(max <= 180);
    return any.doubleInRange(min, max).map(Angle.makeFrom180);
  }

  /// Generates a [Angle] in the full possible range.
  Generator<Angle> get angle => angleInRange(-180, 180);
}

What is the intended way for me to share these generators with consumers of my package, so that they may use them in their unit tests?

I understand that this is more of a general dart question, but I was curious what you people here think about this question. For glados, providing generators along with types could be seen as part of the package interface.

Edit: This is more of a discussion than an issue. If the repo opens a discussion tab, then we can move the issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant