Another little problem: The last test in the series here succeeds, but should fail (I think):
:- begin_tests(correct_catch).
   % This test will succeed as it catches any exception that threw a term that
   % looks like "error(_,_)", which are all ISO standard exception terms.
   test("catch anything",[error(_)]) :-
      must_be(integer,foo).
   % This test will succeed as it expects "type_error" to be thrown,
   % which is what happens.
   
   test("correctly catch type error",error(type_error(_,_))) :-
      must_be(integer,foo).
   % This test will fail because it expects "domain_error" to be thrown,
   % but "type_error" is thrown instead
   
   test("wrongly catch domain error",[error(domain_error(_,_))]) :-
      must_be(integer,foo).
   % Unexpectedly, this test succeeds: it should not, unless the relationship
   % between the "Formal" appearing in the head and the "Formal" appearing in the
   % body is somehow broken when this code is preprocessed/rewritten. A hypotheses for why
   % this test succeeds would be the "Formal" of the head staying fresh in spite
   % of the body saying "Formal = domain_error(_,_)"
   
   test(one,[error(Formal)]) :-        % this catches the exception term thrown by must_be/2
      Formal = domain_error(_,_),  % this is not thorwn by the next instruction
      must_be(integer,foo).
            
:- end_tests(correct_catch).
