hedgehogqa / hedgehogqa/fsharp-hedgehog
Improve Gen.list by only testing [] once
- Dominant language
- F#
- Stars
- 284
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
I want to improve `Gen.list`. Actually, what I really want to do is (better) understand `Gen.list`, and I will be more motivated to do this by having a specific goal to improve it.
Below is code that (if you are lucky) has the following output. It shows that `[]` is tested many times. Maybe I can figure out how to remove the repeated tests of `[]`.
Requiring luck to investigate this issue slows down progress, so it would be nice if #320 were resolved first.
```
[0; 1]
├-[]
├-[1]
| ├-[]
| └-[0]
| └-[]
├-[0]
| └-[]
└-[0; 0]
├-[]
├-[0]
| └-[]
└-[0]
└-[]
```
Here is the shrink tree that I desire.
```
[0; 1]
├-[]
├-[1]
| └-[0]
├-[0]
└-[0; 0]
├-[0]
└-[0]
```
Even though `[0]` is also tested twice, my currently feeling is that it is not reasonable to remove that duplication. That comes from either removing the element at index 0 or the element at index 1. Because both elements are 0, both sublists are the same.
```fsharp
let sample =
Range.constant 0 1
|> Gen.int32
|> Gen.list (Range.constant 0 2)
|> Gen.sampleTree 0 1
|> Seq.head
|> Tree.map (sprintf "%A")
|> Tree.render
printf "%s" sample
```
Contributor guide
Assessment
This issue has not been assessed yet.