Thanks, but this one doesn't solve the issue - I don't think you're surprised by the fact that at the end of the day, || and or probably both use the same opcodes, so they're going to result in the same codepaths to Devel::Cover. The other solutions result in things that look like they might take longer (didn't benchmark yet to be sure), especially since $opts->{foo} really is $self->get_field($opt->{field})->{foo}, so, even if get_field is O(N), it has a significantly higher constant, and so evaluating it twice is an annoyance I'd prefer not to embrace. The || idiom is really perfect here from a readability, maintainability, and speed perspective. It just isn't what Devel::Cover seems to like.
This is why I was hoping for some generic way to tell Devel::Cover to ignore a certain case. e.g., something like:
I guess my alternative is to stop initialising default_foo in the constructor, and have that as a fall-back here:### Devel::Cover: 0 0 ### I know that $self->{default_foo} is neve +r false. my $var = $opts->{foo} || $self->{default_foo};
Maybe Devel::Cover will be able to see there is no way for the last option to be false, and omit it. But then if I want to have a get-routine that gets its current default_foo, I'd have this default in two places, and that is one of the evils I am constantly battling at $work already, so I don't want to go down that road.my $var = $opts->{foo} || $self->{default_foo} || "default value";
In reply to Re^2: Devel::Cover and impossible codepaths
by Tanktalus
in thread Devel::Cover and impossible codepaths
by Tanktalus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |