perl – 如何使用Devel :: Cover标记`//`条件不可用?
发布时间:2020-12-15 23:32:50 所属栏目:大数据 来源:网络整理
导读:我有以下逻辑: sub test { my ($x,$y) = @_; die unless defined $x || defined $y; # uncoverable condition false return $x // $y;}test( 1,2 );test( 1,undef );test( undef,2 );test( undef,undef ); 对于$x和$y都未定义的情况,将永远不会涵盖return语
我有以下逻辑:
sub test { my ($x,$y) = @_; die unless defined $x || defined $y; # uncoverable condition false return $x // $y; } test( 1,2 ); test( 1,undef ); test( undef,2 ); test( undef,undef ); 对于$x和$y都未定义的情况,将永远不会涵盖return语句.因此,覆盖率报告指出该条件未被发现: % | coverage | condition ------------------------------ 67 | A | B | dec | $x // $y |-------------| ===> | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | X | 1 | 我有办法将这种情况标记为不可动摇吗?在行上方添加不可用条件false会修复覆盖率摘要,但是当我查看详细信息时,条件覆盖率仍为67%. Devel :: Cover是否处理//运算符? 另外请注意,如果我将模具线更改为等效线: die "died" if !defined $x && !defined $y; 该线也变为67%. % | coverage | condition ------------------------------ 67 | A | B | dec | defined $x or defined $y |-------------| | 0 | 0 | 0 | ===> | 0 | 1 | 1 | | 1 | X | 1 | 这可能是一个错误吗? 解决方法
这是没有意义的. //只有两个路径(定义了$x,未定义$x). $y与//无关.所以我进行了测试
test( 1,2 ); #test( 1,undef ); # Don't even need this one. test( undef,undef ); 拿到: ----------------------------------- ------ ------ ------ ------ ------ ------ File stmt bran cond sub time total ----------------------------------- ------ ------ ------ ------ ------ ------ x.pl 100.0 100.0 100.0 100.0 100.0 100.0 Total 100.0 100.0 100.0 100.0 100.0 100.0 ----------------------------------- ------ ------ ------ ------ ------ ------ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |