-
Notifications
You must be signed in to change notification settings - Fork 237
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
[Proposal] Migrate to fast-check #353
base: main
Are you sure you want to change the base?
Conversation
key: jsc.elements(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']), | ||
value: jsc.nat, | ||
}) as any | ||
const arbitraryCommand = fc.record({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a built-in way to deal with commands in fast-check. I could probably migrate the test to it.
let numericType = fc | ||
.double({ | ||
next: true, | ||
noDefaultInfinity: true, | ||
noNaN: true, | ||
min: -1 / numericTypeMinAccuracy, | ||
max: 1 / numericTypeMinAccuracy, | ||
}) | ||
}) | ||
.map(d => Math.round(d / numericTypeMinAccuracy) * numericTypeMinAccuracy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the arbitrary fc.double
was able to find potential issues when used with full resolution. Contrary to jsc.number
it can generate any number from -Infinity to +Infinity including -0, Number.MIN_VALUE, Number.EPSILON and others (from small to large values).
// If the above expect(...) assertion fails, we won't reach here. | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for return with fast-check. No return or return true is success. Throw or return false is failure.
What?
This Pull Request is mostly a proposal to migrate from jsverify to fast-check.
Why?
jsverify's owner stopped the maintenance of the library more than a year ago. In addition, the last real commit to jsverify was on the 6th of September 2019.
Benefits of
fast-check
overjsverify
map
(smap
injsverify
).