UTILS = util.cmx console.cmx listx.cmx pure.cmx num.cmx parser.cmx
all: a.out test4.out
- # test.out
run: test4.out
bash run
a.out: $(UTILS) lambda4.cmx problems.cmx
$(OCAMLC) -o a.out $(LIB) $^
-# test.out: $(UTILS) lambda3.cmx test1.ml
-# $(OCAMLC) -o test.out $(LIB) $^
-#
test4.out: $(UTILS) lambda4.cmx test.ml
$(OCAMLC) -o test4.out $(LIB) $^
if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n
;;
-let rec take l n =
+(* let rec take l n =
if n = 0 then []
else match l with
| [] -> []
| x::xs -> x :: (take xs (n-1))
-;;
-
-let test3 n vars =
- let rec aux n inerts lams =
- if n = 0 then take (Util.sort_uniq inerts) 5
- else let inerts, lams = if Random.int 2 = 0
- then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams
- else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams
- in aux (n-1) inerts lams
- in aux (2*n) vars []
-;;
+;; *)
-let test4 n vars =
+let gen n vars =
let rec take' l n =
if n = 0 then [], []
else match l with
let rec repeat f n =
- prerr_endline "\n*************************** NEW TEST ***************************";
+ prerr_endline "\n########################### NEW TEST ###########################";
f () ;
if n > 0 then repeat f (n-1)
;;
-(* let call_main3 tms =
- let _ = (
- List.iter prerr_endline tms; prerr_newline ();
- ) in Lambda3.main [Lambda3.magic tms ["*"]]
-;; *)
-let call_main4 div convs nums =
+let solve div convs nums =
let p = String.concat "\n" (
"$! randomly generated test" ::
("D " ^ div) ::
let complex = 200 in
let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in
- (* let open Parser in *)
-
- (* if three then repeat (fun _ ->
- let tms = test3 complex vars in
- call_main3 tms
- ) num
- else *)
repeat (fun _ ->
- let div, (conv, nums) = test4 complex vars in
- call_main4 div conv nums
+ let div, (conv, nums) = gen complex vars in
+ solve div conv nums
) num
;
+++ /dev/null
-
-
-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 ----"
-;;