exception tests are not easy, because you can't just use equality (for instance, the string in Invalid_argument might not be specified).
If you don't have a specific idea in mind, I propose the following semantic and syntax:
(*$E
<exn matcher> <code to test>
*)
where <exn matcher>: exn -> bool pattern matches an exception, and <code to test>: 'a should raise an exception that is validated by <exn matcher>. A block (*$E f g *) would be encoded into
assert_bool "some message"
( try g; false with e -> f e )
There hasn't been much need for E tests in Batteries, because there are especially compact patterns for that in simple tests, but I see no reason not to implement them.
exception tests are not easy, because you can't just use equality (for instance, the string in
Invalid_argument
might not be specified).If you don't have a specific idea in mind, I propose the following semantic and syntax:
where
<exn matcher>: exn -> bool
pattern matches an exception, and<code to test>: 'a
should raise an exception that is validated by<exn matcher>
. A block(*$E f g *)
would be encoded into