quixir v0.9.1 Quixir.Props

Summary

Functions

assign_locals(properties)
assign_one_local(arg)
has_pinned_vars?(expr)
pin_subexpr(arg, acc)
set_one_param(arg)
set_params(property_list)

Macros

ptest(property_list, options \\ [], block)

The call

ptest v1: type1, v2: type2 do
  « code to test »
end

sets up a property-based test. v1 and v2 are names of variables that will be set to values of types type1 and type2 in the block. The block is run multiple times with different, random-ish values for v1 and v2.

For example:

ptest age: int(min: 0, max: 100), resident: bool do
    assert PollingStation.can_vote(age, resident) == (age >= 18 && resident)
end

As the example shows, types can be parameterized. The parameters for a type may contain references to values for types that precede it in the list. In this case, those values must be flagged with ^.

ptest factor1: int, factor2: int(min: ^factor1, max: 2*^factor1) do
    # ...
end