src/HOL/Mirabelle/Tools/mirabelle_quickcheck.ML
changeset 32521 f20cc66b2c74
parent 32518 e3c4e337196c
child 32564 378528d2f7eb
equal deleted inserted replaced
32518:e3c4e337196c 32521:f20cc66b2c74
     3 *)
     3 *)
     4 
     4 
     5 structure Mirabelle_Quickcheck : MIRABELLE_ACTION =
     5 structure Mirabelle_Quickcheck : MIRABELLE_ACTION =
     6 struct
     6 struct
     7 
     7 
     8 fun quickcheck_action args {pre, timeout, log, ...} =
     8 fun qc_tag id = "#" ^ string_of_int id ^ " quickcheck: "
       
     9 
       
    10 fun init _ = I
       
    11 fun done _ _ = ()
       
    12 
       
    13 fun run args id {pre, timeout, log, ...} =
     9   let
    14   let
    10     val has_valid_key = member (op =) ["iterations", "size", "generator"] o fst
    15     val has_valid_key = member (op =) ["iterations", "size", "generator"] o fst
    11     val quickcheck = Quickcheck.quickcheck (filter has_valid_key args) 1
    16     val quickcheck = Quickcheck.quickcheck (filter has_valid_key args) 1
    12   in
    17   in
    13     (case TimeLimit.timeLimit timeout quickcheck pre of
    18     (case TimeLimit.timeLimit timeout quickcheck pre of
    14       NONE => log "quickcheck: no counterexample"
    19       NONE => log (qc_tag id ^ "no counterexample")
    15     | SOME _ => log "quickcheck: counterexample found")
    20     | SOME _ => log (qc_tag id ^ "counterexample found"))
    16   end
    21   end
    17   handle TimeLimit.TimeOut => log "quickcheck: timeout"
    22   handle TimeLimit.TimeOut => log (qc_tag id ^ "timeout")
       
    23        | ERROR msg => log (qc_tag id ^ "error: " ^ msg)
    18 
    24 
    19 fun invoke args =
    25 fun invoke args =
    20   Mirabelle.register (Mirabelle.catch "quickcheck: " (quickcheck_action args))
    26   Mirabelle.register (init, Mirabelle.catch qc_tag (run args), done)
    21 
    27 
    22 end
    28 end