gen.frequency and oneOf shrinking across alternatives #6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Missing
gen.frequency [ [weight gen] ... ], andgen.oneOfshrinking across alternatives toward the first one.Why
oneOf(lib/gen.nix) picks an alternative and keeps only that alternative's shrinks. Two planned features depend on cross-alternative shrinking:gen.optional: "present -> absent" must be the first shrink step.gen.recursive: depth only shrinks if a node can shrink to a leaf, i.e. to an earlier alternative.Hedgehog's
choice/frequencyshrink the chosen index toward 0 first, then the inner value. nixcheck already has the pieces:Suggested shape
frequencydraws an index from the cumulative weights (rng.below total), shrinks the index toward 0 viabind, then the inner value.oneOf = gens: frequency (map (g: [ 1 g ]) gens).tests/self.nix: a counterexample fromoneOf [ a b ]whereaalso fails shrinks to a value ofa.Foundation for #2, #3 (edge-value mixing), #5.
Implemented in
eedf4c2, pushed to main.