ppx_deriving_qcheck

PPX Deriver for qcheck
README

Documentation

The documentation can be found here.

Arbitrary

Derive QCheck.arbitrary on a type declaration

type tree = Leaf of int | Node of tree * tree
[@@deriving arb]

Overwrite arbitrary

If you wan't to specify your own arbitrary for any type you can
add an attribute to the type:

type t = (int : [@arb QCheck.(0 -- 10)])
[@@deriving arb]

(* produces *)

let arb : t QCheck.arbitrary = QCheck.(0 -- 10)

This attribute has 2 advantages:

  • Use your own arbitrary for a specific type (see above)

  • Arbitrary is not available for a type

    type my_foo =
    | Foo of my_other_type
    | Bar of bool
    [@@deriving arb]
    ^^^^^^^^^^^^^^^^
    Error: Unbound value arb_my_other_type
      
    (* Possible fix *)
    let arb_my_other_type = (* add your implementation here *)
      
    type my_foo =
    | Foo of my_other_type [@arb arb_my_other_type]
    | Bar of bool
    [@@deriving arb]
    

How to use

Install ppx_deriving_qcheck (dev version)

$ opam pin add ppx_deriving_qcheck.dev git+https://github.com/vch9/ppx_deriving_qcheck.git#dev

Add to your OCaml libraries with dune

...
(libraries ppx_deriving_qcheck)
(preprocess (pps ppx_deriving_qcheck)))
...
Install
Sources
v0.1.0.tar.gz
md5=2e144a8c3c7074545478bd0dff430f05
sha512=2883cd669c7c65924aea241dd99e57c2d32bcde1101ef504e3053f3f0b4fc72348ba3aba79b397cbbfa51f164b5f569cb1a01a02a2e3f150097ecd5dcbefe933
Dependencies
alcotest
with-test & >= "1.4.0"
ppxlib
>= "0.22.0"
qcheck
>= "0.17"
ocaml
>= "4.10.2" & < "4.14"
dune
>= "2.8.0"
Reverse Dependencies
ppx_pbt
>= "0.2.1"