9 val auto: bool ref |
9 val auto: bool ref |
10 val auto_time_limit: int ref |
10 val auto_time_limit: int ref |
11 val test_term: Proof.context -> bool -> string option -> int -> int -> term -> |
11 val test_term: Proof.context -> bool -> string option -> int -> int -> term -> |
12 (string * term) list option |
12 (string * term) list option |
13 val add_generator: string * (Proof.context -> term -> int -> term list option) -> theory -> theory |
13 val add_generator: string * (Proof.context -> term -> int -> term list option) -> theory -> theory |
|
14 val quickcheck: (string * string) list -> int -> Proof.state -> (string * term) list option |
14 end; |
15 end; |
15 |
16 |
16 structure Quickcheck : QUICKCHECK = |
17 structure Quickcheck : QUICKCHECK = |
17 struct |
18 struct |
18 |
19 |
213 in |
214 in |
214 thy |
215 thy |
215 |> (Data.map o apsnd o map_test_params) f |
216 |> (Data.map o apsnd o map_test_params) f |
216 end; |
217 end; |
217 |
218 |
218 fun quickcheck_cmd args i state = |
219 fun quickcheck args i state = |
219 let |
220 let |
220 val prf = Toplevel.proof_of state; |
221 val thy = Proof.theory_of state; |
221 val thy = Toplevel.theory_of state; |
222 val ctxt = Proof.context_of state; |
222 val ctxt = Toplevel.context_of state; |
|
223 val default_params = (dest_test_params o snd o Data.get) thy; |
223 val default_params = (dest_test_params o snd o Data.get) thy; |
224 val f = fold (parse_test_param_inst ctxt) args; |
224 val f = fold (parse_test_param_inst ctxt) args; |
225 val (((size, iterations), default_type), (generator_name, insts)) = |
225 val (((size, iterations), default_type), (generator_name, insts)) = |
226 f (default_params, (NONE, [])); |
226 f (default_params, (NONE, [])); |
227 val counterex = test_goal false generator_name size iterations |
227 in |
228 default_type insts i [] prf; |
228 test_goal false generator_name size iterations default_type insts i [] state |
229 in (Pretty.writeln o pretty_counterex ctxt) counterex end; |
229 end; |
|
230 |
|
231 fun quickcheck_cmd args i state = |
|
232 quickcheck args i (Toplevel.proof_of state) |
|
233 |> Pretty.writeln o pretty_counterex (Toplevel.context_of state); |
230 |
234 |
231 local structure P = OuterParse and K = OuterKeyword in |
235 local structure P = OuterParse and K = OuterKeyword in |
232 |
236 |
233 val parse_arg = P.name --| P.$$$ "=" -- P.name; |
237 val parse_arg = P.name --| P.$$$ "=" -- P.name; |
234 val parse_args = P.$$$ "[" |-- P.list1 parse_arg --| P.$$$ "]" |
238 val parse_args = P.$$$ "[" |-- P.list1 parse_arg --| P.$$$ "]" |