-
I'm trying to test a compare function very simplified I'm trying to do something like this: fc.assert(
fc.property(
fc.string(),
fc.string(),
(a,b) => {
const result = compare(a, b);
return result === (a===b);
})
) With just random values for If could do fc.assert(
fc.property(
fc.oneof(fc.string(), fc.constant("a")),
fc.oneof(fc.string(), fc.constant("a")),
(a,b) => {
const result = compare(a,b);
return result === (a===b);
})
) But then I only test with a constant, Ideally I would like be able to describe that the two arbitraries should share the same value with a probability. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey, Actually, with fast-check you don't really have to bother with such constraints. The case 'a === b' will not be that unlikely as the framework uses some bias internally that makes collisions more likely. Otherwise if you really want the same value twice you may want to use |
Beta Was this translation helpful? Give feedback.
Hey,
Actually, with fast-check you don't really have to bother with such constraints. The case 'a === b' will not be that unlikely as the framework uses some bias internally that makes collisions more likely.
Otherwise if you really want the same value twice you may want to use
fc.clone
.