Skip to content

Understanding Arbitrary #4487

Answered by dubzzz
baetheus asked this question in Q&A
Nov 27, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

At first glance, your Arbitrary looks great. There are some refinement that could be made:

  • The second argument passed to fc.Value is never used in your case: It is supposed to be leveraged at shrinking time to get back how the values have been built (if and only if you want to provide a shrinker).

  • The canShrinkWithoutContext is not symmetric with shrink, or more precisely your shrink seems buggy: The method shrink will either be called with the context passed as a second argument of fc.Value or with undefined in case canShrinkWithoutContext returned true.

You probably lost too much context in generate if you want to shrink anything:

export class IntersectArbitrary<U, V> extends fc.A…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@baetheus
Comment options

Answer selected by baetheus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants