Subject: | IPv6 first/last bug |
first() and last() don't always do the right thing for IPv6 addresses.
$ perl -MNetAddr::IP -le 'print $NetAddr::IP::VERSION'
4.041
$ cat ipv6_first_last.t
use strict;
use warnings;
use Test::More tests => 2;
use NetAddr::IP;
my $ipv6 = NetAddr::IP->new( '2001::E/127' );
is $ipv6->first, "2001:0:0:0:0:0:0:E/127", "first address is 2001::E";
is $ipv6->last, "2001:0:0:0:0:0:0:F/127", "last address is 2001::F";
exit;
$ prove -v ./ipv6_first_last.t
./ipv6_first_last.t ..
1..2
not ok 1 - first address is 2001::E
# Failed test 'first address is 2001::E'
# at ./ipv6_first_last.t line 11.
# got: '2001:0:0:0:0:0:0:F/127'
# expected: '2001:0:0:0:0:0:0:E/127'
not ok 2 - last address is 2001::F
# Failed test 'last address is 2001::F'
# at ./ipv6_first_last.t line 12.
# got: '2001:0:0:0:0:0:0:E/127'
# expected: '2001:0:0:0:0:0:0:F/127'
# Looks like you failed 2 tests of 2.
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests
Test Summary Report
-------------------
./ipv6_first_last.t (Wstat: 512 Tests: 2 Failed: 2)
Failed tests: 1-2
Non-zero exit status: 2
Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.03 cusr
0.00 csys = 0.05 CPU)
Result: FAIL