package alg_structs_qcheck

  1. Overview
  2. Docs
Provides qCheck generators for laws of alg_structs

Install

Dune Dependency

Authors

Maintainers

Sources

alg_structs_qcheck-0.1.3.tbz
sha256=6b0113f2500e70fd00862879ba36d64e9e0f1815ad6ffe2325b1e5e8ed561c08
sha512=80e7a34fb04791221df44d876482a562a48b8e84665258be556fefc1cb77c380425bff7b1f52939bffbf69d78d223ff428e936f7a32dccb7901c6f06783cd764

doc/index.html

Alg_structs_qcheck: qCheck tests for Alg_structs

API

See the API reference.

Summary

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.

Examples

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 = List.map 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
        end);

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

        (module struct
            include Functor.Array
            let name = "Functor.Array"
            let arbitrary = array
        end);
    ]

(* Runs the tests *)
let () = Alcotest.run "alg" [ functor_laws ]
OCaml

Innovation. Community. Security.