Alg_structs_qcheck: qCheck tests for Alg_structs


See the API reference.


Support for generating QCheck tests for the structures supplied by Alg_structs.

Each of the modules for supported structures in the API reference provides three things:

  1. A signature S that specifies an interface for a module that can be used to generate a suite of QCheck tests to check for violations of the structures laws.
  2. A function test that takes a module satisfying S and produces a set of tests to check for the laws.
  3. A function tests that takes a list of modules satisfying S and produces a list of tests, as per test, for each implementation supplied.


Here is an example of how to use this library to generat tests for various implementations of Functor:

open QCheck
open Alg_structs

(* A convenience wrapper for QCheck and Alcotest *)
let suite name tests =
let tests = QCheck_alcotest.to_alcotest tests in
(name, tests)

let functor_laws =
let open Alg_structs_qcheck.Functor in
suite "Functor Laws" @@ tests
        (module struct
            include Functor.Option
            let name = "Functor.Option"
            let arbitrary = option

        (module struct
            include Functor.List
            let name = "Functor.List"
            let arbitrary = list

        (module struct
            include Functor.Array
            let name = "Functor.Array"
            let arbitrary = array

(* Runs the tests *)
let () = "alg" [ functor_laws ]