[enhancement] quickcheck constraints
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
### What's hard to do? (limit 100 words)
quickcheck works well when the input is constrained naturally by a type. However, oftentimes, I've found a need to constrain the value beyond this type. Quickcheck does not appear to support adding constraints as part of the metadata.
### Current best alternative workaround (limit 100 words)
You can 1) ignore the sample by explicitly returning true for that case, e.g.
https://github.com/google/xls/blob/8c8ad0284fa8475ab5fd5fbda2de03f3950b6002/xls/examples/quickcheck.x#L33
This reduces the number of actual useful samples in the quickcheck.
Or 2) compose the actual value with multiple inputs to satisfy the constraint. This may affect the statistical distribution compared to a properly constrained input.
### Your view of the "best case XLS enhancement" (limit 100 words)
It'd be nice to be able to do:
```
#[quickcheck(constraint="x%2 == 0 && x != 42")]
fn foo(x: u32) -> bool {
```
or similar
Contributor guide
Assessment
This issue has not been assessed yet.