From ade646a9ae308c0ceacbfb82d85eb4552bec77b2 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Thu, 7 Jun 2018 19:43:58 +0200 Subject: [PATCH] More randomness in test generation --- ocaml/simple_test.ml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ocaml/simple_test.ml b/ocaml/simple_test.ml index 3ec4bb7..ed2c81c 100644 --- a/ocaml/simple_test.ml +++ b/ocaml/simple_test.ml @@ -36,23 +36,23 @@ let gen n vars = let rec repeat f n = print_endline "\n########################### NEW TEST ###########################"; - f () ; + f n ; if n > 0 then repeat f (n-1) ;; let main = Random.self_init (); - let num = 100 in - let complex = 100 in - let no_bound_vars = 10 in - let vars = Array.to_list - (Array.init no_bound_vars (fun x -> "x" ^ string_of_int x)) in - + let num = 1000 in + (*let complex = 100 in + let no_bound_vars = 10 in*) let file = Filename.temp_file ~temp_dir:"./problems/" "simple.constants.auto." "" in let oc = open_out file in print_endline ("\n\n---- " ^ file) ; - - repeat (fun _ -> + repeat (fun x -> + let complex = 100 + x / 10 in + let no_bound_vars = Random.int 20 + 1 in + let vars = Array.to_list + (Array.init no_bound_vars (fun x -> "x" ^ string_of_int x)) in let div, convs = gen complex vars in let str = " \nD " ^ div ^ String.concat "\nC " convs ^ "\n" in print_endline str; @@ -62,7 +62,6 @@ let main = let str = "$ failing test problem \n# Failed because: " ^ Printexc.to_string e ^ str in Printf.fprintf oc "%s\n" str ) num ; - close_out oc; print_endline ("\n\n---- " ^ file); let filesize filename = -- 2.39.2