老实说,我不确定这是一个错误还是我错过了什么 .

Devel::Cover 以某种方式基于先前的条件忽略了我的 # uncoverable branch true .

我有2个文件 - TestTest2 - uncoverableTest 中 .

现在当触发条件(见下文)没有被注释掉时,我获得了50%的分支覆盖率,如下所示:

现在注释掉触发条件并再次运行一切,我得到:

现在,分支被正确地忽略为不可移动的 . 唯一被改变的是评论触发条件 .

我真的不明白这种行为 - 如果有人愿意尝试这一点,看看这是不是我不理解某些东西或错误 .

免责声明:我不是perl guru :)我试图更多地简化这一点,但我无法重现它 - 否则即使是简化也可以了 - 也许它会帮助追踪它的根本原因 .

EDIT :我做了这个回购,以便更容易重现:https://github.com/lukaskuzmiak/Devel--Cover_coverage_issue_PoC

package My::Test;

use 5.026;
use strict;
use warnings;

use My::Test2;


sub test {

    my $test2 = My::Test2->new({});

    if ($test2 > 1) { say 'something'; } # let's call this "trigger condition"

    # uncoverable branch true
    $test2->asdf(
        {
            variable => 'asdf'
        }
    ) or say 'something else';

    return 1;
}

1;

还有第二个 Test2

package My::Test2;

use 5.026;
use strict;
use warnings;

sub new {
    my ($class, $args) = @_;
    my $self = {};
    return bless $self, $class;
}

sub asdf {
    my ($class, $args) = @_;
    return 1;
}

1;