Skip to content

Commit

Permalink
Use Fmt.exn instead of Printexc.to_string
Browse files Browse the repository at this point in the history
For consistency and maybe better formatting too.
  • Loading branch information
MisterDA committed Jun 5, 2023
1 parent ce8e72e commit 1f25d40
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/alcotest-engine/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ let check_raises ?here ?pos msg exn f =
match collect_exception f with
| None ->
check_err (fun ppf () ->
Fmt.pf ppf "%t%a %s: expecting %s, got nothing."
(pp_location ?here ?pos) Pp.tag `Fail msg (Printexc.to_string exn))
Fmt.pf ppf "%t%a %s: expecting %a, got nothing."
(pp_location ?here ?pos) Pp.tag `Fail msg Fmt.exn exn)
| Some e ->
if e <> exn then
check_err (fun ppf () ->
Fmt.pf ppf "%t%a %s: expecting %s, got %s." (pp_location ?here ?pos)
Pp.tag `Fail msg (Printexc.to_string exn) (Printexc.to_string e))
Fmt.pf ppf "%t%a %s: expecting %a, got %a." (pp_location ?here ?pos)
Pp.tag `Fail msg Fmt.exn exn Fmt.exn e)

let match_raises ?here ?pos msg exnp f =
show_assert msg;
Expand All @@ -249,8 +249,8 @@ let match_raises ?here ?pos msg exnp f =
| Some e ->
if exnp e then
check_err (fun ppf () ->
Fmt.pf ppf "%t%a %s: got %s." (pp_location ?here ?pos) Pp.tag `Fail
msg (Printexc.to_string e))
Fmt.pf ppf "%t%a %s: got %a." (pp_location ?here ?pos) Pp.tag `Fail
msg Fmt.exn e)

let skip () = raise Core.Skip
let () = at_exit (Format.pp_print_flush Format.err_formatter)

0 comments on commit 1f25d40

Please sign in to comment.