Skip to content

Commit

Permalink
QCHECK_LONG_FACTOR environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vch9 committed Jan 7, 2022
1 parent 3398d13 commit 8d72a74
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/core/QCheck2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1394,13 +1394,19 @@ module Test = struct

let default_count = 100

let global_count count =
let count = match (count, Sys.getenv_opt "QCHECK_COUNT") with
let default_long_factor = 1

let global_positive_var default env_var var =
let var = match (var, Sys.getenv_opt env_var) with
| (Some x, _) -> x
| (_, Some x) -> int_of_string x
| (None, None) -> default_count
| (None, None) -> default
in
if count <= 0 then invalid_arg ("count must be > 0 but value is " ^ string_of_int count) else count
if var <= 0 then invalid_arg (env_var ^ " must be > 0 but value is " ^ string_of_int var) else var

let global_count count = global_positive_var default_count "QCHECK_COUNT" count

let global_long_factor long_factor = global_positive_var 1 "QCHECK_LONG_FACTOR" long_factor

let fresh_name =
let r = ref 0 in
Expand All @@ -1409,10 +1415,11 @@ module Test = struct
let default_if_assumptions_fail = `Warning, 0.05

let make_cell ?(if_assumptions_fail=default_if_assumptions_fail)
?(count) ?(long_factor=1) ?max_gen
?(count) ?long_factor ?max_gen
?(max_fail=1) ?(retries=1) ?(name=fresh_name()) ?print ?collect ?(stats=[]) gen law
=
let count = global_count count in
let long_factor = global_long_factor long_factor in
let max_gen = match max_gen with None -> count + 200 | Some x->x in
{
law;
Expand Down

0 comments on commit 8d72a74

Please sign in to comment.