forked from alanfalloon/ocaml-quickcheck
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.ml
37 lines (25 loc) · 884 Bytes
/
test.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
open QuickCheck
let prop_revrev xs =
List.rev (List.rev xs) = xs
let prop_mem xs = match xs with
| [] -> true
| (x::_) -> List.mem x xs
let prop_str_copy s = s = (String.copy s)
(* for generating random int lists *)
let al = arbitrary_list arbitrary_int
(* for printing out int lists *)
let sl = show_list show_int
(* for being able to test (int list -> bool) *)
let testable_list_to_bool = testable_fun al sl testable_bool
let cl = quickCheck testable_list_to_bool
let testable_str_to_bool = testable_fun arbitrary_string show_string testable_bool
let cs = quickCheck testable_str_to_bool
let void f = fun a -> let _ = f a in ()
let () =
(void cl) prop_revrev;
(void cl) prop_mem;
(void cs) prop_str_copy;
match cl prop_revrev with
| Success -> ()
| Failure _ -> failwith "No failure expected"
| Exhausted _ -> failwith "No exhaustion expected"