src/HOL/Mirabelle/Tools/mirabelle_quickcheck.ML
author wenzelm
Sat, 12 Sep 2009 16:30:48 +0200
changeset 32564 378528d2f7eb
parent 32521 f20cc66b2c74
child 32567 de411627a985
permissions -rw-r--r--
standard headers and text sections;

(*  Title:      HOL/Mirabelle/Tools/mirabelle_quickcheck.ML
    Author:     Jasmin Blanchette and Sascha Boehme, TU Munich
*)

structure Mirabelle_Quickcheck : MIRABELLE_ACTION =
struct

fun qc_tag id = "#" ^ string_of_int id ^ " quickcheck: "

fun init _ = I
fun done _ _ = ()

fun run args id {pre, timeout, log, ...} =
  let
    val has_valid_key = member (op =) ["iterations", "size", "generator"] o fst
    val quickcheck = Quickcheck.quickcheck (filter has_valid_key args) 1
  in
    (case TimeLimit.timeLimit timeout quickcheck pre of
      NONE => log (qc_tag id ^ "no counterexample")
    | SOME _ => log (qc_tag id ^ "counterexample found"))
  end
  handle TimeLimit.TimeOut => log (qc_tag id ^ "timeout")
       | ERROR msg => log (qc_tag id ^ "error: " ^ msg)

fun invoke args =
  Mirabelle.register (init, Mirabelle.catch qc_tag (run args), done)

end