Is there any difference in behavior when reusing the same Arbitrary
instance vs. using distinct instances?
#3530
Answered
by
dubzzz
jmartinezmaes
asked this question in
Q&A
-
💬 Question and HelpDoes this: import * as fc from "fast-check";
const strUpper = fc.string().map((s) => s.toUpperCase());
fc.assert(fc.property(strUpper, strUpper, (x, y) => { /* asserts here */ })); and this: import * as fc from "fast-check";
function strUpper(): fc.Arbitrary<string> {
return fc.string().map((s) => s.toUpperCase());
}
fc.assert(fc.property(strUpper(), strUpper(), (x, y) => { /* asserts here */ })); have any difference in functionality? |
Beta Was this translation helpful? Give feedback.
Answered by
dubzzz
Jan 1, 2023
Replies: 1 comment
-
I'd say there is no difference at all. All arbitraries are stateless and re-using or not the instance has no impact on fast-check's behaviour, it's supposed to behave fully the same. The function approach is closer to the APIs of fast-check, but while it makes sense in the library to offer configurable arbitraries it's mostly up to the user when it's for user specific arbitraries. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jmartinezmaes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd say there is no difference at all. All arbitraries are stateless and re-using or not the instance has no impact on fast-check's behaviour, it's supposed to behave fully the same.
The function approach is closer to the APIs of fast-check, but while it makes sense in the library to offer configurable arbitraries it's mostly up to the user when it's for user specific arbitraries.