Gathering Statistics: Aggregating
Learn about the aggregate function and how to use it in properties.
Aggregate
The aggregate function is similar to the collect function with one simple exception. The aggregate function can take a list of categories to store. Let’s look at the function in action.
Code
Let’s start off with a basic property that uses the function. Take a look at it in the code below:
-module(prop_generators).
-include_lib("proper/include/proper.hrl").
-compile(export_all).
prop_aggregate() ->
Suits = [club, diamond, heart, spade],
?FORALL(Hand, vector(5, {oneof(Suits), choose(1,13)}),
aggregate(Hand, true)). % `true' makes it always pass
The aggregate function
This property’s generator creates a hand of five cards in a list. The ...
Ask