Add tests for backtraces from forcing lazy values

master
Leo White 2020-04-18 14:43:47 +01:00
parent ca64723db3
commit 9895b28d25
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,28 @@
(* TEST
flags = "-g"
compare_programs = "false"
* native
*)
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

View File

@ -0,0 +1,11 @@
Uncaught exception Not_found
Raised at Lazy.l1 in file "lazy.ml", line 8, characters 28-45
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lazy.run in file "lazy.ml", line 20, characters 4-11
Uncaught exception Not_found
Raised at Lazy.l2 in file "lazy.ml", line 13, characters 28-45
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lazy.test2 in file "lazy.ml", line 16, characters 6-15
Called from Lazy.run in file "lazy.ml", line 20, characters 4-11