anchor.diff:  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%% ad-hoc unit testing
   
  +unit_quiet() ->
  +  [R||R<-unit(),is_tuple(R)].
  +
   unit() ->
     lists:foldr(
       fun(Str,O)->[unit(fun transform/1,Str)|O]end,[],
  -    [{"a",
  -      {{a,'_','_'},[{'_',[],[]}],[local]}}
  +    [{"a when element(1,'$_')=/=b",
  +      {{a,'_','_'},
  +       [{'_',[{'=/=',{element,1,'$_'},b}],[]}],[local]}}
  +     ,{"a:b when element(1,'$_')=/=c",
  +       {{a,b,'_'},
  +        [{'_',[{'=/=',{element,1,'$_'},c}],[]}],[local]}}
  +     ,{"a",
  +       {{a,'_','_'},[{'_',[],[]}],[local]}}
        ,{"a",
          {{a,'_','_'},[{'_',[],[]}],[local]}}
        ,{"a->stack",
  
positive.code:        {{a,b,2},[{['$1','$1'],[],[]}],[local]}}
       ,{"a:b(X,y)",
         {{a,b,2},[{['$1',y],[],[]}],[local]}}
       ,{" a:foo()when a==b",
         {{a,foo,0},[{[],[{'==',a,b}],[]}],[local]}}
       ,{"a:b(X,1)",
         {{a,b,2},[{['$1',1],[],[]}],[local]}}
       ,{"a:b(X,\"foo\")",
  
negative.code: split_fun(Str) ->
    fun() ->
        % strip off the actions, if any
        {St,Action} = 
          case re:run(Str,"^(.+)->\\s*([a-z;]+)\\s*\$",[{capture,[1,2],list}]) of
            {match,[Z,A]} -> {Z,A};
            nomatch       -> {Str,""}
          end,
        % strip off the guards, if any
        {S,Guard} = 
          case re:run(St,"^(.+[\\s)])+when\\s(.+)\$",[{capture,[1,2],list}]) of
            {match,[Y,G]} -> {Y,G};
            nomatch       -> {St,""}
          end,
        % add a wildcard F, if Body is just an atom (presumably a module)
        Body =
          case re:run(S,"^\\s*[a-zA-Z0-9_]+\\s*\$") of
            nomatch -> S;
            _       -> S++":'_'"
          end,
        {Body,Guard,Action}
    end.
  
  