let acaso l = let n = Random.int (List.length l) in List.nth l n ;; let acaso2 l1 l2 = let n1 = List.length l1 in let n = Random.int (n1 + List.length l2) in if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n ;; let rec take l n = if n = 0 then [] else match l with | [] -> [] | x::xs -> x :: (take xs (n-1)) ;; let test1 n vars = let rec aux n l = if n = 0 then take (Util.sort_uniq l) 3 else aux (n-1) (("(" ^ (acaso l) ^ " " ^ (acaso l) ^ ")") :: l) in aux n vars ;; let test2 n vars = let rec aux n ins lams = if n = 0 then take (Util.sort_uniq ins) 5 else let ins, lams = if Random.int 2 = 0 then ins, ("(" ^ acaso vars ^ ". " ^ acaso2 ins lams ^ ")") :: lams else ("(" ^ acaso ins ^ " " ^ acaso2 ins lams^ ")") :: ins, lams in aux (n-1) ins lams in aux (2*n) vars [] ;; let rec repeat f n = f () ; if n > 0 then repeat f (n-1);; let call_main tms = let _ = ( prerr_endline "\n*************************** NEW TEST ***************************"; List.iter prerr_endline tms; prerr_endline ""; ) in Lambda3.main [Lambda3.magic tms ["*"]] ;; let main = Random.self_init (); (*Random.init 1000;*) let num = 100 in let complex = 200 in let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in let open Parser in let open Lambda3 in (* test1 *) repeat (fun _ -> let tms = test1 complex vars in call_main tms ) num ; (* test2 *) repeat (fun _ -> call_main (test2 complex vars) ) num ; prerr_endline "\n---- ALL TESTS COMPLETED ----" ;;