jobjo / popper

Property-based testing at ease
ISC License
43 stars 1 forks source link

Add more comparators #6

Closed jobjo closed 3 years ago

jobjo commented 3 years ago

Comparator.t values are for supporting comparison and pretty printing. They are used for the Popper.equal function:

val equal
  :  ?loc:string
  -> 'a Comparator.t
  -> 'a
  -> 'a
  -> Proposition.t Sample.t

Current API of Comparator.

type 'a t

val make : ('a -> 'a -> int) -> (Format.formatter -> 'a -> unit) -> 'a t
val compare : 'a t -> 'a -> 'a -> int
val pp : 'a t -> Format.formatter -> 'a -> unit

val int : int t
val float : float t
val bool : bool t
val string : string t

val tuple : 'a t -> 'b t -> ('a * 'b) t
val list : 'a t -> 'a list t
val array : 'a t -> 'a array t
val option : 'a t -> 'a option t
val result : ok:'a t -> error:'e t -> ('a, 'e) result t

Should add some missing primitives and combinators. See similar combinators for Alcotest here

jobjo commented 3 years ago

Addressed in https://github.com/jobjo/popper/commit/af8958a342b388edbcb8a9a10cd9c2048863229b