On Jul 11, 2004, at 4:09 PM, James Mastros wrote:
package Foo;
sub new { my $class=shift; $class=ref($class)||$class;
bless [], $class; }
eval { Foo::new(); } is($!, "new dies when called as a function");
Actually this doesn't die, it does even worse, given this code:
package Foo;
sub new { my $class=shift; $class=ref($class)||$class; bless [], $class; }
package main;
my $foo = Foo::new(); print $foo;
The output is:
main=ARRAY(0x180035c)
The array gets blessed into the "main" package, which will of course eventually die when you try and call a method from "main::" and it can't find it.
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.
I agree, 100% full coverage is many times an unreasonable goal. Personally I am satisfied at 95% or above. That is not to say that I wont try to squeeze out a little more coverage if I think it will actually be useful to the tests. But if you are just covering to cover, you are not necessarily improving the quality of the tests, which in the end is the ultimate goal.
Steve