Questions tagged [smallcheck]

SmallCheck is a testing library that allows to verify properties for all test cases up to some depth. The test cases are generated automatically by SmallCheck.

SmallCheck is a testing library that allows to verify properties for all test cases up to some depth. The test cases are generated automatically by SmallCheck.

Test.SmallCheck

This module exports the main pieces of SmallCheck functionality.

To generate test cases for your own types, refer to Test.SmallCheck.Series.

For pointers to other sources of information about SmallCheck, please refer to the README at https://github.com/feuerbach/smallcheck/blob/master/README.md

Constructing tests

The simplest kind of test is a function (possibly of many arguments) returning Bool. The function arguments are interpreted as being universally, existentially or uniquely quantified, depending on the quantification context.

The default quantification context is universal (forAll).

forAll, exists and existsUnique functions set the quantification context for function arguments. Depending on the quantification context, the test \x y -> p x y may be equivalent to:

∀ x, y. p x y (forAll)
∃ x, y: p x y (exists)
∃! x, y: p x y (existsUnique)

The quantification context affects all the variables immediately following the quantification operator, also extending past over, changeDepth and changeDepth1 functions.

However, it doesn't extend past other functions, like monadic, and doesn't affect the operands of ==>. Such functions start a fresh default quantification context.

Examples

\x y -> p x y means ∀ x, y. p x y
exists $ \x y -> p x y means ∃ x, y: p x y
exists $ \x -> forAll $ \y -> p x y means ∃ x: ∀ y. p x y
existsUnique $ \x y -> p x y means ∃! (x, y): p x y
existsUnique $ \x -> over s $ \y -> p x y means ∃! (x, y): y ∈ s && p x y
existsUnique $ \x -> monadic $ \y -> p x y means ∃! x: ∀ y. [p x y]
existsUnique $ \x -> existsUnique $ \y -> p x y means ∃! x: ∃! y: p x y
exists $ \x -> (\y -> p y) ==> (\z -> q z) means ∃ x: (∀ y. p y) => (∀ z. p z)
20 questions
1
vote
2 answers

SmallCheck generate data satisfying invariants

I want to use SmallCheck to test my code. I managed to generate arbitrary lists of pairs of ints, but that's not what my type should contain. The list represents a set of ranges, where [1,3),[4,6) would be encoded/stored as [(1,3),(4,6)]. These are…
Filip Haglund
  • 13,919
  • 13
  • 64
  • 113
1
vote
1 answer

What does symdiff does (in haskell)

I am supposed to fill in something for undefined to get the program compiled and test it. I don't really know what symdiff here is supposed to do, so I don't know what I can fill in for undefined. Can someone give me a hint, what I can insert into…
Peter
  • 1,679
  • 2
  • 31
  • 60
0
votes
1 answer

SmallCheck: check infinity of the set of Ints

The set of integers is infinite, so for any n <- Z there is some m > n, and I try to show it with SmallCheck test: ... , testProperty "infinity of integers set" $ forAll $ \(n::Integer) -> exists $ \m -> m > n ... It fails with: ... …
RandomB
  • 3,367
  • 19
  • 30
0
votes
1 answer

Golden test within smallcheck property test

I have a manually-written "golden test" (write actual output to file, compare to "golden" expected file for equality) within a smallcheck property which enumerates over all of the constructors for a given enum. I would like to convert this to…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
0
votes
1 answer

Round problem involving the calculation of compound interest in python

I did a work for school which I had to submit on a website that verificated if the output requested matched mine. Well,the program is about compond interests: I had to create something that given a certain debt,interest and number of years without…
1
2