-
Notifications
You must be signed in to change notification settings - Fork 3
/
testing.ml
28 lines (26 loc) · 1.06 KB
/
testing.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
open Core
exception Check_equal_fail of string * string * string * string
exception Check_equal_exc of string * string * string * string
(*
make_check_equal : ?string -> ?('a -> string) -> unit -> ?string ->
(unit -> 'a) -> 'a ->
unit
*)
let make_check_equal ?(test_module = "")
?(to_string = (fun _ -> "#<abstr>"))
()
?(name = "")
compute_actual
expected =
let actual = (try compute_actual ()
with any_exn ->
raise (Check_equal_exc (test_module,
name,
to_string expected,
Exn.to_string any_exn))) in
if actual = expected
then ()
else raise (Check_equal_fail (test_module,
name,
to_string actual,
to_string expected))