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

sum-types: Support random testing for enums #1611

Closed
RyanGlScott opened this issue Jan 19, 2024 · 1 comment
Closed

sum-types: Support random testing for enums #1611

RyanGlScott opened this issue Jan 19, 2024 · 1 comment
Labels
enums Issues related to enums feature request Asking for new or improved functionality

Comments

@RyanGlScott
Copy link
Contributor

On the sum-types branch (#1602), it is not currently possible to randomly test expressions involving enums, e.g.,

enum T = MkT

f : T -> Bool
f _ = True
Main> :check f
cryptol: src/Cryptol/Testing/Random.hs:(169,7)-(172,37): Non-exhaustive patterns in case

At a minimum, we should make Cryptol produce a proper error message here. We should also consider implementing random testing support for enums like we do for other types. We'll need to think carefully about what distribution of constructors is desirable. For instance, if we have:

enum Maybe a
  = Nothing
  | Just a

Then it is arguably more desirable to generate more Just values than Nothing values. Perhaps there is a simple way to encode this metric in the enum distribution that we use.

@RyanGlScott RyanGlScott added feature request Asking for new or improved functionality enums Issues related to enums labels Jan 19, 2024
@RyanGlScott
Copy link
Contributor Author

Support for random testing of enum values was added in 9438d83.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enums Issues related to enums feature request Asking for new or improved functionality
Projects
None yet
Development

No branches or pull requests

1 participant