src/Tools/quickcheck.ML
changeset 45419 10ba32c347b0
parent 45418 e5ef7aa77fde
child 45449 eeffd04cd899
equal deleted inserted replaced
45418:e5ef7aa77fde 45419:10ba32c347b0
    48   val add_report : int -> report option -> result Unsynchronized.ref -> unit
    48   val add_report : int -> report option -> result Unsynchronized.ref -> unit
    49   val counterexample_of : result -> (string * term) list option
    49   val counterexample_of : result -> (string * term) list option
    50   val timings_of : result -> (string * int) list
    50   val timings_of : result -> (string * int) list
    51   (* registering testers & generators *) 
    51   (* registering testers & generators *) 
    52   type tester =
    52   type tester =
    53     Proof.context -> (string * typ) list -> (term * term list) list -> result list
    53     Proof.context -> bool -> (string * typ) list -> (term * term list) list -> result list
    54   val add_tester : string * (bool Config.T * tester) -> Context.generic -> Context.generic
    54   val add_tester : string * (bool Config.T * tester) -> Context.generic -> Context.generic
    55   val add_batch_generator :
    55   val add_batch_generator :
    56     string * (Proof.context -> term list -> (int -> term list option) list)
    56     string * (Proof.context -> term list -> (int -> term list option) list)
    57       -> Context.generic -> Context.generic
    57       -> Context.generic -> Context.generic
    58   val add_batch_validator :
    58   val add_batch_validator :
   190     Test_Params {default_type = default_type2, expect = expect2}) =
   190     Test_Params {default_type = default_type2, expect = expect2}) =
   191   make_test_params
   191   make_test_params
   192     (merge (op =) (default_type1, default_type2), merge_expectation (expect1, expect2));
   192     (merge (op =) (default_type1, default_type2), merge_expectation (expect1, expect2));
   193 
   193 
   194 type tester =
   194 type tester =
   195   Proof.context -> (string * typ) list -> (term * term list) list -> result list
   195   Proof.context -> bool -> (string * typ) list -> (term * term list) list -> result list
   196 
   196 
   197 structure Data = Generic_Data
   197 structure Data = Generic_Data
   198 (
   198 (
   199   type T =
   199   type T =
   200     ((string * (bool Config.T * tester)) list
   200     ((string * (bool Config.T * tester)) list
   286 fun test_terms ctxt (limit_time, is_interactive) insts goals =
   286 fun test_terms ctxt (limit_time, is_interactive) insts goals =
   287   case active_testers ctxt of
   287   case active_testers ctxt of
   288     [] => error "No active testers for quickcheck"
   288     [] => error "No active testers for quickcheck"
   289   | testers => limit (seconds (Config.get ctxt timeout)) (limit_time, is_interactive)
   289   | testers => limit (seconds (Config.get ctxt timeout)) (limit_time, is_interactive)
   290       (fn () => Par_List.get_some (fn tester =>
   290       (fn () => Par_List.get_some (fn tester =>
   291       tester ctxt insts goals |>
   291       tester ctxt (length testers > 1) insts goals |>
   292       (fn result => if exists found_counterexample result then SOME result else NONE)) testers)
   292       (fn result => if exists found_counterexample result then SOME result else NONE)) testers)
   293       (fn () => (message ctxt "Quickcheck ran out of time"; NONE)) ();
   293       (fn () => (message ctxt "Quickcheck ran out of time"; NONE)) ();
   294       
   294       
   295 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state =
   295 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state =
   296   let
   296   let