Papylon is a Python library for random testing of program properties.
We can write a simple property with Python code:
from papylon.prop import for_all
from papylon.arbitrary import arb_list, arb_int
from papylon.checker import check
# reversed and reversed list is the same of the original list
p1 = for_all([arb_list(arb_int(), max_length=20)],
lambda x: list(reversed(list(reversed(x)))) == x)
check(p1)When we run the script above, we can see the result as following:
OK, passed 100 tests.
If a property failed, Papylon reports which arbitrary(s) made it failed:
import math
p2 = for_all([arb_int()], lambda n: math.sqrt(n*n) == n)
check(p2)Falsified after 2 tests (31 shrinks):
> [-1]