summaryrefslogtreecommitdiff
path: root/testsuite/tests/backtrace/lazy.ml
blob: 362539a9f7816d7f0b2073b63055ce96a632f8f6 (plain)
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
(* TEST_BELOW *)

let l1 : unit lazy_t = lazy (raise Not_found)

let test1 () =
  let () = Lazy.force l1 in ()

let l2 : unit lazy_t = lazy (raise Not_found)

let test2 () =
  let (lazy ()) = l2 in ()

let run test =
  try
    test ();
  with exn ->
    Printf.printf "Uncaught exception %s\n" (Printexc.to_string exn);
    Printexc.print_backtrace stdout

let () =
  Printexc.record_backtrace true;
  run test1;
  run test2


(* TEST
 flags = "-g";
 {
   no-flambda;
   native;
 }{
   reference = "${test_source_directory}/lazy.flambda.reference";
   flambda;
   native;
 }
*)