5 let n = Random.int (List.length l) in
10 let n1 = List.length l1 in
11 let n = Random.int (n1 + List.length l2) in
12 if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n
15 (** with bombs and pacmans too *)
17 if Random.int 10 = 0 then (
18 if Random.int 2 = 0 then "BOMB" else "PAC"
20 let n1 = List.length l1 in
21 let n = Random.int (n1 + List.length l2) in
22 if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n
29 | x::xs -> x :: (take xs (n-1))
38 | x1::x2::xs -> let a, b = take' xs (n-1) in x1::a,x2::b in
39 let rec aux n inerts lams =
40 if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5
41 else let inerts, lams = if Random.int 2 = 0
42 then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams
43 else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams
44 in aux (n-1) inerts lams
54 | x1::x2::xs -> let a, b = take' xs (n-1) in x1::a,x2::b in
55 let rec aux n inerts lams =
56 if n = 0 then List.hd inerts, take' (Util.sort_uniq (List.tl inerts)) 5
57 else let inerts, lams = if Random.int 2 = 0
58 then inerts, ("(" ^ acaso vars ^ ". " ^ acaso3 inerts lams ^ ")") :: lams
59 else ("(" ^ acaso inerts ^ " " ^ acaso3 inerts lams^ ")") :: inerts, lams
60 in aux (n-1) inerts lams
66 prerr_endline "\n########################### NEW TEST ###########################";
68 if n > 0 then repeat f (n-1)
71 let solve div convs nums =
72 let p = String.concat "\n" (
73 "$! randomly generated test" ::
75 List.map ((^) "C ") convs @
76 List.map (fun s -> "N " ^ s ^ " Z") nums
79 (Lambda4.solve ++ Lambda4.problem_of ++ Parser.problem_of_string) p
84 (* num = number of tests to run *)
86 (* if flag --with-pac active, then more general tests *)
87 let with_pac = List.mem "--with-pac" (Array.to_list Sys.argv) in
92 let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in
93 fun () -> gen_pac complex vars
96 let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in
97 fun () -> gen complex vars
101 let div, (conv, nums) = f () in
105 prerr_endline "\n---- ALL TESTS COMPLETED ----"