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

Derive zio.test.Gen #161

Merged
merged 2 commits into from Dec 14, 2021
Merged

Derive zio.test.Gen #161

merged 2 commits into from Dec 14, 2021

Conversation

ghost
Copy link

@ghost ghost commented Dec 10, 2021

My second attempt on resolving #56.
I've renewed this pr due to recent changes in zio-schema

@ghost ghost marked this pull request as ready for review December 11, 2021 22:14
@ghost ghost self-requested a review as a code owner December 11, 2021 22:14
@ghost
Copy link
Author

ghost commented Dec 11, 2021

@thinkharderdev Hey Dan! Could you have a look at this PR?!

Copy link
Contributor

@thinkharderdev thinkharderdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One small comment but I think this is ready to merge otherwise.

Comment on lines 464 to 468
private def genSequence[Z, A](seq: Schema.Sequence[Z, A]): Gen[Random with Sized, Z] =
Gen.chunkOf1(gen(seq.schemaA)).map(nec => seq.fromChunk(nec.toChunk))

private def genMap[K, V](map: Schema.MapSchema[K, V]): Gen[Random with Sized, Map[K, V]] =
Gen.mapOf1(gen(map.ks), gen(map.vs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these two I would not restrict to single-element chunks (at the very least we should sometimes generate an empty Chunk). So maybe a chunk bounded by 0 and 2? I know in other places we run into severe performance issues if we don't restrict to small(ish) collection sized.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was concerned about chunk's arbitrary size and that's why I did single-element chunks).
No problem, I will bound the chunk by 0 and 2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@thinkharderdev thinkharderdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@thinkharderdev thinkharderdev merged commit c252e37 into zio:main Dec 14, 2021
landlockedsurfer pushed a commit to landlockedsurfer/zio-schema that referenced this pull request May 28, 2022
Co-authored-by: Dan Harris <1327726+thinkharderdev@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

1 participant