ocaml-core / base / core / lib / quickcheck.mli

The branch 'bash' does not exist.
(** Module for easily generating unit tests.  Based on code posted by
    padiolea\@irisa.fr to the caml mailing list. *)

(** the type of a random ['a]-generator *)
type 'a gen = unit -> 'a

(** positive float generator *)
val pfg : float gen

(** float generator (no nan, inf, etc.) *)
val fg : float gen

(** natural number generator *)
val nng : int gen

(** unsigned int generator (uniform random in range min_int, max_int) *)
val uig : int gen

(** char generator *)
val cg : char gen

(** pair generator *)
val pg : 'a gen -> 'b gen -> ('a * 'b) gen

(** triple generator *)
val tg : 'a gen -> 'b gen -> 'c gen -> ('a * 'b * 'c) gen

(** list generator *)
val lg : 'a gen -> ?size_gen:int gen -> 'a list gen

(** string generator *)
val sg : ?char_gen : char gen -> ?size_gen : int gen -> string gen

(** Given a list of generators, returns generator that randomly uses one of the
    generators from the list *)
val oneof : 'a gen list -> 'a gen

(** generator that always returns given value *)
val always : 'a -> 'a gen

(** Given list of [(frequency,value)] pairs, returns value with probability
    proportional to given frequency *)
val frequency : (int * 'a) list -> 'a

(** a [gen]-returning version of [frequency] *)
val frequencyl : (int * 'a) list -> 'a gen

(** [repeat n test t] tests that the first [n] values generated by [t]
    all pass [test] *)
val repeat : int -> ('a -> unit) -> 'a gen -> unit

(** [laws iter gen func] applies [func] repeatedly ([iter] times) on output
    of [gen], and if [func] ever returns false, then the input that caused
    the failure is returned optionally. *)
val laws : int -> 'a gen -> ('a -> bool) -> 'a option

(** Like laws, but throws an exception instead of returning an option. *)
val laws_exn : string -> int -> 'a gen -> ('a -> bool) -> unit
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.