-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_debug_html.ml
44 lines (32 loc) · 1.31 KB
/
test_debug_html.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
38
39
40
41
42
43
44
open Sexplib0.Sexp_conv
module Debug_runtime =
(val Minidebug_runtime.debug_file ~hyperlink:"../" ~toc_specific_hyperlink:"./"
~with_toc_listing:true
~backend:(`Html PrintBox_html.Config.(tree_summary true default))
"debugger_sexp_html")
let%debug_sexp foo (x : int) : int list =
let y : int = x + 1 in
[ x; y; 2 * y ]
let () = ignore @@ List.hd @@ foo 7
type t = { first : int; second : int } [@@deriving sexp]
let%debug_sexp bar (x : t) : int =
let y : int = x.first + 1 in
x.second * y
let () = ignore @@ bar { first = 7; second = 42 }
let%debug_sexp baz (x : t) : int =
let ((y, z) as _yz : int * int) = (x.first + 1, 3) in
let ((u, w) as _uw : int * int) = (7, 13) in
(x.second * y) + z + u + w
let () = ignore @@ baz { first = 7; second = 42 }
let%debug_sexp lab ~(x : int) : int list =
let y : int = x + 1 in
[ x; y; 2 * y ]
let () = ignore @@ List.hd @@ lab ~x:7
let%debug_sexp rec loop (depth : int) (x : t) : int =
if depth > 4 then x.first + x.second
else if depth > 1 then loop (depth + 1) { first = x.second + 1; second = x.first / 2 }
else
let y : int = loop (depth + 1) { first = x.second - 1; second = x.first + 2 } in
let z : int = loop (depth + 1) { first = x.second + 1; second = y } in
z + 7
let () = ignore @@ loop 0 { first = 7; second = 42 }