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

Address nullability issue with Arb.edgecase #4029

Open
Kantis opened this issue May 20, 2024 · 2 comments
Open

Address nullability issue with Arb.edgecase #4029

Kantis opened this issue May 20, 2024 · 2 comments
Milestone

Comments

@Kantis
Copy link
Member

Kantis commented May 20, 2024

An Arb<T>, where T is nullable currently has no way of expressing the null edgecase, since returning null from Arb.edgecase is interpreted as "no edgecase exists" by the property testing framework.

Suggestion

Change Arb<T>.edgecase(rs: RandomSource): T? to Arb<T>.edgecase(rs: RandomSource): Sample<T>?. Returning null can still be interpreted as no edgecase exists. Sample lets us box the null edgecase so it can be represented as well.

Reference

@Kantis Kantis added this to the 6.0 milestone May 20, 2024
@AlexCue987
Copy link
Contributor

Is this a good use case for Kotlin's own Result?

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/

@Kantis
Copy link
Member Author

Kantis commented May 20, 2024

Arb interface already uses Sample to communicate samples being pulled from the Arb.

abstract fun sample(rs: RandomSource): Sample<A>

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

2 participants