anchor.diff:      ok.
       
   
  -error_handling(doc) ->
  -    ["Test that errors are handled correctly by the erlang code."];
  -error_handling(Config) when is_list(Config) ->
  +%% Test that errors are handled correctly by the erlang code.
  +error_handling(_Config) ->
  +    case test_server:is_native(re) of
  +	true ->
  +	    %% Exceptions from native code look too different.
  +	    {skip,"re is native"};
  +	false ->
  +	    error_handling()
  +    end.
  +	    
  +error_handling() ->
       % This test checks the exception tuples manufactured in the erlang
       % code to hide the trapping from the user at least when it comes to errors
       Dog = ?t:timetrap(?t:minutes(1)),
  
positive.code:     % the trap to re:grun from grun, in the grun function clause
      % that handles precompiled expressions
      ?line {'EXIT',{badarg,[{re,run,["apa",{1,2,3,4},[global]],_},
  			   {?MODULE,error_handling,1,_} | _]}} =
  	(catch re:run("apa",{1,2,3,4},[global])),
      % An invalid capture list will also cause a badarg late, 
      % but with a non pre compiled RE, the exception should be thrown by the
      % grun function clause that handles RE's compiled implicitly by
      % the run/3 BIF before trapping.
      ?line {'EXIT',{badarg,[{re,run,["apa","p",[{capture,[1,{a}]},global]],_},
  			   {?MODULE,error_handling,1,_} | _]}} =
  	(catch re:run("apa","p",[{capture,[1,{a}]},global])),
      % And so the case of a precompiled expression together with
      % a compile-option (binary and list subject):
  
negative.code: 			    [<<"apa">>,
  			     {re_pattern,1,0,_},
  			     [global,unicode]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:run(<<"apa">>,RE,[global,unicode])),
      ?line {'EXIT',{badarg,[{re,run,
  			    ["apa",
  			     {re_pattern,1,0,_},
  			     [global,unicode]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:run("apa",RE,[global,unicode])),
      ?line {'EXIT',{badarg,_}} = (catch re:run("apa","(p",[])),
      ?line {'EXIT',{badarg,_}} = (catch re:run("apa","(p",[global])),
      % The replace errors:
      ?line {'EXIT',{badarg,[{re,replace,["apa",{1,2,3,4},"X",[]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:replace("apa",{1,2,3,4},"X",[])),
      ?line {'EXIT',{badarg,[{re,replace,["apa",{1,2,3,4},"X",[global]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:replace("apa",{1,2,3,4},"X",[global])),
      ?line {'EXIT',{badarg,[{re,replace,
  			    ["apa",
  			     {re_pattern,1,0,_},
  			     "X",
  			     [unicode]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:replace("apa",RE,"X",[unicode])),
      ?line <<"aXa">> = iolist_to_binary(re:replace("apa","p","X",[])),
      ?line {'EXIT',{badarg,[{re,replace,
  			    ["apa","p","X",[{capture,all,binary}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch iolist_to_binary(re:replace("apa","p","X",
  					  [{capture,all,binary}]))),
      ?line {'EXIT',{badarg,[{re,replace,
  			    ["apa","p","X",[{capture,all}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch iolist_to_binary(re:replace("apa","p","X",
  					  [{capture,all}]))),
      ?line {'EXIT',{badarg,[{re,replace,
  			    ["apa","p","X",[{return,banana}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch iolist_to_binary(re:replace("apa","p","X",
  					  [{return,banana}]))),
      ?line {'EXIT',{badarg,_}} = (catch re:replace("apa","(p","X",[])),
      % Badarg, not compile error.
      ?line {'EXIT',{badarg,[{re,replace,
  			    ["apa","(p","X",[{return,banana}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch iolist_to_binary(re:replace("apa","(p","X",
  					  [{return,banana}]))),
      % And the split errors:
      ?line [<<"a">>,<<"a">>] = (catch re:split("apa","p",[])),
      ?line [<<"a">>,<<"p">>,<<"a">>] = (catch re:split("apa",RE,[])),
      ?line {'EXIT',{badarg,[{re,split,["apa","p",[global]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa","p",[global])),
      ?line {'EXIT',{badarg,[{re,split,["apa","p",[{capture,all}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa","p",[{capture,all}])),
      ?line {'EXIT',{badarg,[{re,split,["apa","p",[{capture,all,binary}]],_},
  			   {?MODULE, error_handling,0,_} | _]}} =
  	(catch re:split("apa","p",[{capture,all,binary}])),
      ?line {'EXIT',{badarg,[{re,split,["apa",{1,2,3,4},[]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa",{1,2,3,4})),
      ?line {'EXIT',{badarg,[{re,split,["apa",{1,2,3,4},[]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa",{1,2,3,4},[])),
      ?line {'EXIT',{badarg,[{re,split,
  			    ["apa",
  			     RE,
  			     [unicode]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa",RE,[unicode])),
      ?line {'EXIT',{badarg,[{re,split,
  			    ["apa",
  			     RE,
  			     [{return,banana}]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa",RE,[{return,banana}])),
      ?line {'EXIT',{badarg,[{re,split,
  			    ["apa",
  			     RE,
  			     [banana]],_},
  			   {?MODULE,error_handling,0,_} | _]}} =
  	(catch re:split("apa",RE,[banana])),
      ?line {'EXIT',{badarg,_}} = (catch re:split("apa","(p")),
      %Exception on bad argument, not compilation error
  