| 1 | 1 | ▶ | use NetAddr::IP::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | my $nets = { | |||||||||||||||||||||||||||
| 4 | '10.1.2.3' => [ 32, 0 ], | ||||||||||||||||||||||||||||
| 5 | '10.2.3.4' => [ 31, 1 ], | ||||||||||||||||||||||||||||
| 6 | '10.0.0.16' => [ 24, 255 ], | ||||||||||||||||||||||||||||
| 7 | '10.128.0.1' => [ 8, 2 ** 24 - 1 ], | ||||||||||||||||||||||||||||
| 8 | '10.0.0.5' => [ 30, 3 ], | ||||||||||||||||||||||||||||
| 9 | '0.0.0.0' => [ 0, 2 ** 32 -1 ], | ||||||||||||||||||||||||||||
| 10 | }; | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | my $new = 1; # flag for old vs new numeric returns | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | $| = 1; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | $test = keys %$nets; | |||||||||||||||||||||||||||
| 17 | 1 | $test *= 2; | |||||||||||||||||||||||||||
| 18 | 1 | print "1..", $test, "\n"; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | $test = 1; | |||||||||||||||||||||||||||
| 21 | 2 | ▶ | sub tst { | ||||||||||||||||||||||||||
|
Subroutine
tst: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 22 | 2 | for my $a (keys %$nets) { | |||||||||||||||||||||||||||
| 23 | 12 | my $nc = $nets->{$a}->[1] - $new; # net count | |||||||||||||||||||||||||||
| 24 | 12 | ▶ | $nc = 1 if $nc < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 12 | ▶ | $nc = 2 if $new && $nets->{$a}->[0] == 31; # special case for /31, /127 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$new and $nets->{$a}[0] == 31
MC/DC100%2/2
$new and $nets->{$a}[0] == 31
$new
$nets->{$a}[0] == 31
Truth table100%3/3
A and B
A= $newB= $nets->{$a}[0] == 31
| |||||||||||||||||||||||||||||
| 26 | 12 | my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; | |||||||||||||||||||||||||||
| 27 | 12 | ▶ | print "got: $_, exp: $nc\nnot " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | unless ($_ = $ip->num) == $nc; | ||||||||||||||||||||||||||||
| 29 | 12 | print "ok ", $test++, "\n"; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | tst(); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | import NetAddr::IP::Lite qw(:old_nth); | |||||||||||||||||||||||||||
| 36 | 1 | $new = 0; | |||||||||||||||||||||||||||
| 37 | 1 | tst(); | |||||||||||||||||||||||||||