Example #1
0
def prop(a: A, x: [number]):
    sub_set = a.some_of(x)
    return len(sub_set) <= len(x)


@qc.forall("Arbitrary some_of should return non empty list")
def prop(a: A, x: non_empty_list):
    sub_set = a.some_of(x, empty=False)
    return len(sub_set) >= 1


@qc.forall("Arbitrary one of")
def prop(a: A, x: non_empty_list):
    element = a.one_of(*x)
    return element in x


@qc.forall("A.shuffle of any given list should result list of the same size")
def prop(a: A, x: [number]):
    shuffled = a.shuffle(x)
    return len(shuffled) == len(x)


@qc.forall("Shuffled singleton list should be the same")
def prop(a: A, x: number):
    shuffled = a.shuffle([x])
    return shuffled == [x]


TestSpec = qc.as_testcase()
Example #2
0
import unittest
from quick.features import forall, QuickCheck
from quick.generators import *
from quick.arbitrary import A

qc = QuickCheck()


@qc.forall('Maybe generator')
def prop(x: maybe(None)):
    return x is None


TestSpec = qc.as_testcase()