src/Tools/quickcheck.ML
changeset 42616 92715b528e78
parent 42433 b48d9186e883
child 43018 121aa59b4d17
equal deleted inserted replaced
42607:c8673078f915 42616:92715b528e78
   130 
   130 
   131 fun merge_expectation (expect1, expect2) =
   131 fun merge_expectation (expect1, expect2) =
   132   if expect1 = expect2 then expect1 else No_Expectation
   132   if expect1 = expect2 then expect1 else No_Expectation
   133 
   133 
   134 (* quickcheck configuration -- default parameters, test generators *)
   134 (* quickcheck configuration -- default parameters, test generators *)
   135 val (tester, setup_tester) = Attrib.config_string "quickcheck_tester" (K "")
   135 val tester = Attrib.setup_config_string @{binding quickcheck_tester} (K "")
   136 val (size, setup_size) = Attrib.config_int "quickcheck_size" (K 10)
   136 val size = Attrib.setup_config_int @{binding quickcheck_size} (K 10)
   137 val (iterations, setup_iterations) = Attrib.config_int "quickcheck_iterations" (K 100)
   137 val iterations = Attrib.setup_config_int @{binding quickcheck_iterations} (K 100)
   138 val (no_assms, setup_no_assms) = Attrib.config_bool "quickcheck_no_assms" (K false)
   138 val no_assms = Attrib.setup_config_bool @{binding quickcheck_no_assms} (K false)
   139 val (report, setup_report) = Attrib.config_bool "quickcheck_report" (K true)
   139 val report = Attrib.setup_config_bool @{binding quickcheck_report} (K true)
   140 val (timing, setup_timing) = Attrib.config_bool "quickcheck_timing" (K false)
   140 val timing = Attrib.setup_config_bool @{binding quickcheck_timing} (K false)
   141 val (quiet, setup_quiet) = Attrib.config_bool "quickcheck_quiet" (K false)
   141 val quiet = Attrib.setup_config_bool @{binding quickcheck_quiet} (K false)
   142 val (timeout, setup_timeout) = Attrib.config_real "quickcheck_timeout" (K 30.0)
   142 val timeout = Attrib.setup_config_real @{binding quickcheck_timeout} (K 30.0)
   143 val (finite_types, setup_finite_types) = Attrib.config_bool "quickcheck_finite_types" (K true)
   143 val finite_types = Attrib.setup_config_bool @{binding quickcheck_finite_types} (K true)
   144 val (finite_type_size, setup_finite_type_size) =
   144 val finite_type_size = Attrib.setup_config_int @{binding quickcheck_finite_type_size} (K 3)
   145   Attrib.config_int "quickcheck_finite_type_size" (K 3)
       
   146 
       
   147 val setup_config =
       
   148   setup_tester #> setup_size #> setup_iterations #> setup_no_assms #> setup_report #> setup_timing
       
   149     #> setup_quiet #> setup_timeout #> setup_finite_types #> setup_finite_type_size
       
   150 
   145 
   151 datatype test_params = Test_Params of
   146 datatype test_params = Test_Params of
   152   {default_type: typ list, expect : expectation};
   147   {default_type: typ list, expect : expectation};
   153 
   148 
   154 fun dest_test_params (Test_Params {default_type, expect}) = (default_type, expect);
   149 fun dest_test_params (Test_Params {default_type, expect}) = (default_type, expect);
   534       else
   529       else
   535         (false, state)
   530         (false, state)
   536   end
   531   end
   537 
   532 
   538 val setup = Auto_Tools.register_tool (auto, auto_quickcheck)
   533 val setup = Auto_Tools.register_tool (auto, auto_quickcheck)
   539   #> setup_config
       
   540 
   534 
   541 (* Isar commands *)
   535 (* Isar commands *)
   542 
   536 
   543 fun read_nat s = case (Library.read_int o Symbol.explode) s
   537 fun read_nat s = case (Library.read_int o Symbol.explode) s
   544  of (k, []) => if k >= 0 then k
   538  of (k, []) => if k >= 0 then k