-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathmock_mt.ml
29 lines (27 loc) · 1.1 KB
/
mock_mt.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
type eq = Mt.eq =
| Eq : 'a *'a -> eq
| Neq : 'a * 'a -> eq
| StrictEq : 'a *'a -> eq
| StrictNeq : 'a * 'a -> eq
| Ok : bool -> eq
| Approx : float * float -> eq
| ApproxThreshold : float * float * float -> eq
| ThrowAny : (unit -> unit) -> eq
| Fail : unit -> eq
| FailWith : string -> eq
type pair_suites = (string * (unit -> eq)) list
let from_pair_suites (name : string) (suites : pair_suites) =
Js.log (name, "testing");
List.iter (fun (name, code) ->
match code () with
| Eq(a,b) -> Js.log (name , a, "eq?", b )
| Neq(a,b) -> Js.log (name, a, "neq?", b )
| StrictEq(a,b) -> Js.log (name , a, "strict_eq?", b )
| StrictNeq(a,b) -> Js.log (name, a, "strict_neq?", b )
| Approx(a,b) -> Js.log (name, a, "~", b)
| ApproxThreshold(t, a, b) -> Js.log (name, a, "~", b, " (", t, ")")
| ThrowAny fn -> ()
| Fail _ -> Js.log "failed"
| FailWith msg -> Js.log ("failed: " ^ msg)
| Ok a -> Js.log (name, a, "ok?")
) suites