[erlang-questions] Test Coverage -- proposed patch in erl_pp

Thomas Arts thomas.arts@REDACTED
Sat Sep 8 18:53:01 CEST 2007


For cover analysis during testing it is important to see each clause in a case statement on a separate line. In fact, coverage should not be done by lines, but by statements, clauses, etc, but assume you use the test server, then line coverage is what you get.

You do not want to write a function like this:

case X of
     true -> 12; false -> 14
end.
when testing for coverage and using line coverage. You can get rather strange results. Instead you want:
case X of
     true -> 12; 
     false -> 14
end.

If you write the code yourself, you will take care of this. However, erl_pp typesets code a bit differently. Sometimes it likes it better as the clause given above.

I patched my erl_pp to contain:
clauses(Type, Hook, Cs) ->
    {prefer_nl,[$;],lexprs(Cs, Type, Hook)}.

from the original
clauses(Type, Hook, Cs) ->
    expr_list(Cs, [$;], Type, Hook). 

Would that be a good patch or are there arguments against it that I haven't considered?
/Thomas



More information about the erlang-questions mailing list