title: Test Exception Raise in Ocaml
body: <p>I have written a simple non-negative number Fibonacci function in OCaml, where I raise an exception if a negative number is passed in.</p>
  
  <pre><code>let rec fib (n:int) : int =
    match n with
    | a when a &lt; 0 -&gt; invalid arg ("Positive numbers only")
    | i when i &lt; 2 -&gt; n
    | _ -&gt; fib (n - 1) + fib(n - 2)
  
    let _ = assert (fib(-1))
  </code></pre>
  
  <p>The function is very rudimentary (it's my first OCaml program), but my question involves testing that an exception is raised when I execute <code>fib(-1)</code>.</p>
  
  <pre><code>let _ = assert (? = fib(-1))
  </code></pre>
  
  <p>How do I assert for this exception?</p>