Adding more tests, fixing one test for miniImp, adding more functionality to miniFun
This commit is contained in:
@ -10,7 +10,7 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%d\n" (reduce 1 program)
|
||||
Printf.printf "Identity program: %d\n" (reduce program 1)
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* y not defined program *)
|
||||
@ -28,13 +28,13 @@ let program =
|
||||
;;
|
||||
|
||||
try
|
||||
Printf.printf "%d\n" (reduce 100 program)
|
||||
Printf.printf "y not defined program: %d\n" (reduce program 100)
|
||||
with AbsentAssignment s ->
|
||||
Printf.printf "%s\n" s
|
||||
Printf.printf "y not defined program: %s\n" s
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* factorial program *)
|
||||
(* Factorial program *)
|
||||
let program =
|
||||
Main
|
||||
("a",
|
||||
@ -53,11 +53,11 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%d\n" (reduce 10 program)
|
||||
Printf.printf "Factorial program: %d\n" (reduce program 10)
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* hailstone sequence's lenght program *)
|
||||
(* Hailstone sequence's lenght program *)
|
||||
let program =
|
||||
Main
|
||||
("a",
|
||||
@ -79,11 +79,11 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%d\n" (reduce 77031 program)
|
||||
Printf.printf "Hailstone sequence's lenght program: %d\n" (reduce program 77031)
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* sum multiples of 3 and 5 program *)
|
||||
(* Sum multiples of 3 and 5 program *)
|
||||
let program =
|
||||
Main
|
||||
("a",
|
||||
@ -92,7 +92,7 @@ let program =
|
||||
(Assignment ("b", (Integer 0))),
|
||||
(For (
|
||||
(Assignment ("i", Integer 0)),
|
||||
(BCmpLess (Variable "i", Variable "a")),
|
||||
(BCmpLessEq (Variable "i", Variable "a")),
|
||||
(Assignment ("i", Plus (Variable "i", Integer 1))),
|
||||
(If (
|
||||
(BOr ((BCmp (Modulo (Variable "i", Integer 3), Integer 0)),
|
||||
@ -105,11 +105,11 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%d\n" (reduce 12345 program)
|
||||
Printf.printf "Sum multiples of 3 and 5 program: %d\n" (reduce program 12345)
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* rand program *)
|
||||
(* Rand program *)
|
||||
let program =
|
||||
Main
|
||||
("a",
|
||||
@ -118,11 +118,11 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%b\n" ((reduce 10 program) < 10)
|
||||
Printf.printf "Rand program: %b\n" ((reduce program 10) < 10)
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
(* fibonacci program *)
|
||||
(* Fibonacci program *)
|
||||
let program =
|
||||
Main
|
||||
("n",
|
||||
@ -148,7 +148,7 @@ let program =
|
||||
)
|
||||
;;
|
||||
|
||||
Printf.printf "%d\n" (reduce 48 program)
|
||||
Printf.printf "Fibonacci program: %d\n" (reduce program 48)
|
||||
;;
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
@ -215,8 +215,8 @@ let program =
|
||||
;;
|
||||
|
||||
(* should return 0 because prime *)
|
||||
Printf.printf "%d\n" (reduce 179424673 program)
|
||||
Printf.printf "Miller-Rabin primality test program: %d\n" (reduce program 179424673)
|
||||
;;
|
||||
(* sould return 1 because not prime *)
|
||||
Printf.printf "%d\n" (reduce 179424675 program)
|
||||
(* should return 1 because not prime *)
|
||||
Printf.printf "Miller-Rabin primality test program: %d\n" (reduce program 179424675)
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user