> I would love to used PBT more, but many tests I write have only one answer per input. Think sum like aggregations.
Not quite sure what you mean by "only one answer per input" (that it's a function, i.e. a 1:1 mapping?), but there are of lots of properties that aggregations might typically need to satisfy, e.g. off the top of my head:
# Identity element
forAll(pre, post) {
assertEqual(
agg(pre ++ [agg([])] ++ post),
agg(pre ++ post)
)
}
# Invariant to order
forAll(elems, seed) {
assertEqual(
agg(elems),
agg(permute(elems, seed))
)
}
# Left-associative
forAll(xs, ys, zs) {
assertEqual(
agg([agg(xs ++ ys)] ++ zs),
agg(xs ++ ys ++ zs)
)
}
# Right-associative
forAll(xs, ys, zs) {
assertEqual(
agg(xs ++ [agg(yz ++ zs)]),
agg(xs ++ ys ++ zs)
)
}
(FYI these typical properties of a (commutative) monoid, which is an algebraic structure that describes many "aggregation-like" operations)