Skip to content

Commit

Permalink
Fix Jqwik memoization equals bug (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongahjo authored Jun 16, 2023
1 parent db94000 commit 43013ff
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,21 @@ private CombinableArbitrary generateIntrospected(
generated = generated.filter(predicate);
}

FixtureCustomizer customizer = ctx.getFixtureCustomizers().stream()
.filter(it -> it.match(node.getProperty()))
.map(MatcherOperator::getOperator)
.findFirst()
.orElse(null);
boolean hasCustomizer = ctx.getFixtureCustomizers().stream()
.anyMatch(it -> it.match(node.getProperty()));

CombinableArbitrary arbitrary = generated;
if (customizer != null) {
arbitrary = new FixedCombinableArbitrary(
generated.combined().map(obj -> customizer.customizeFixture(obj))
);
if (hasCustomizer) {
arbitrary = new FixedCombinableArbitrary(generated.combined());
}

return arbitrary;
return arbitrary.map(
object -> ctx.getFixtureCustomizers().stream()
.filter(it -> it.match(node.getProperty()))
.map(MatcherOperator::getOperator)
.findFirst()
.map(it -> it.customizeFixture(object))
.orElse(object)
);
}
}

0 comments on commit 43013ff

Please sign in to comment.