On Sun, Jul 11, 2004 at 10:09:38PM +0200, James Mastros wrote:
> 
> All unreachable code is either people misusing the term "unreachable", a 
> bug in Devel::Cover, or dead code that should be removed.

Here's a puzzle, then.

I just ran into a similar "problem" in POE::Driver::SysRW.  For
portability I have a couple lines similar to

    $! = 0 if $! == EAGAIN or $! == EWOULDBLOCK;

EAGAIN and EWOULDBLOCK are identical on most systems.  In fact, one is
usually defined in terms of the other.  They differ on a few platforms,
however, and it's important to check both.

The expression boils down to this on my test system:

    A   B   dec   $! == 35 or $! == 35
    0   0   0     (green, tested)
    0   1   0     (red, impossible to test)
    1   X   1     (green, tested)

> It may be possible to notice that you're running under Devel::Cover and
> run the "look under every rock" tests only in that case.  But if it's
> your goal to cover everything and get that 100% there, then you need to
> try harder before declaring something unreachable.
> 
> Note that this shouldn't be construed as saying that you should create
> insane tests, just to get 100% coverage.  My point is almost the exact
> oppisate: that it's not reasonable to try for 100% conditional coverage.

While I'd like 100% coverage, I've decided to live with 98.3% because of
these untestable (at least on my machine) conditions.  It's nice to have
the red flags pointing at some silly code, and maybe an improvement will
come later.

I don't advocate that the improvement appear in Perl or Devel::Cover.
On the contrary, logic errors like this should be pointed out to make
better code.

-- 
Rocco Caputo - http://poe.perl.org/

Reply via email to