5 List.mem "--with-const" (Array.to_list Sys.argv)
9 let n = Random.int (List.length l) in
14 let n1 = List.length l1 in
15 let n = Random.int (n1 + List.length l2) in
16 if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n
25 | x::_::xs -> x :: take' xs (n-1) in
26 let rec aux n inerts lams =
27 if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5
28 else let inerts, lams = if Random.int 2 = 0
29 then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams
30 else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams
31 in aux (n-1) inerts lams in
32 let inerts = if with_const then "C" :: vars else vars in
38 print_endline "\n########################### NEW TEST ###########################";
40 if n > 0 then repeat f (n-1)
46 (*let complex = 100 in
47 let no_bound_vars = 10 in*)
48 let file = Filename.temp_file ~temp_dir:"./problems/" "simple.constants.auto." "" in
49 let oc = open_out file in
50 print_endline ("\n\n---- <TESTS> " ^ file) ;
52 let complex = 100 + x / 10 in
53 let no_bound_vars = Random.int 20 + 1 in
54 let vars = Array.to_list
55 (Array.init no_bound_vars (fun x -> "x" ^ string_of_int x)) in
56 let div, convs = gen complex vars in
57 let str = " \nD " ^ div ^ String.concat "\nC " convs ^ "\n" in
60 (solve ++ problem_of ++ Parser.problem_of_string) ("$" ^ str)
61 with Failure _ as e ->
62 let str = "$! failing test problem \n# Failed because: " ^ Printexc.to_string e ^ str in
63 Printf.fprintf oc "%s\n" str
67 print_endline ("\n\n---- </TESTS> " ^ file);
68 let filesize filename =
69 let ic = open_in filename in
70 let size = in_channel_length ic in
73 then (print_endline "---- All tests succeeded."; Sys.remove file )
74 else (print_endline ("---- Not all tests succeeded. See " ^ file))