On Sat, Jan 05, 2008 at 12:53:35PM +0100, nadim khemir wrote: > Next problem is coverage. Nothing upsets me more than a 99.8% coverage. I'd > almost prefere a 80% coverage to 99.8%. > > So I tried to test that case with > > { > use IO::File; > my $current_fh = select ; > > my $fh = new IO::File; # not opened > select $fh ; > > throws_ok > { > $object->DoPrint() ; > } > qr/can't print!/, 'print failed' ; > > select $current_fh ; > } > > with DoPrint looking something like: > > print 'hi' or carp q{can't print!} ;
I'm not quite sure what you are getting at here. If you really want to test the return value of every print statement (and personally, I can think of much better things to do with my time), and you want coverage of both successful and unsuccessful prints (and other similar functions, I suppose), then you'll have to fake up or otherwise arrange for both successful and unsuccessful calls. This appears to be what you are doing. If you are saying that you want to code for failed prints, but don't want to actually test them, but still want 100% coverage (I don't think this is what you are saying because it makes no sense), then you will have to cheat. # uncoverable condition right note:I want 100% coverage without testing this print 'hi' or carp q{can't print!} ; But if you do this and then test a failed print you will get a coverage error because you did something you said was impossible. I think I must be missing something. What is it that is stopping you from getting your final 0.2% coverage? -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net