neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
Greetings,
Why does the last test fail?
#!/usr/bin/perl use Regexp::Common qw/ net number /; use Test::More; use strict; use warnings; my $valid_host = qr/\A (?: $RE{net}{IPv6} ) | (?: $RE{net}{IPv4} ) | (?: $RE{net}{domain}{-nospace}{-rfc1101}\.? ) \Z/x; like('luna.example.com', $valid_host, 'valid long hostname' ); like('luna', $valid_host, 'valid short hostname' ); like('fe80::42:5eff:feef:8f4f', $valid_host, 'valid ipv6 ip' ); like('10.0.0.1', $valid_host, 'valid ipv4 ip' ); unlike('10.0 24', $valid_host, 'invalid host or ip' ); done_testing; ok 1 - valid long hostname ok 2 - valid short hostname ok 3 - valid ipv6 ip ok 4 - valid ipv4 ip not ok 5 - invalid hostname or ip # Failed test 'invalid hostname or ip' # at /home/neil/src/neil/test/ipv4.pl line 22. # '10.0 24' # matches '(?^x:\A # .... # # \Z)' 1..5 # Looks like you failed 1 test of 5.
Neil Watson
watson-wilson.ca
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regexp::common::net unexpected failure
by Corion (Patriarch) on Nov 24, 2016 at 20:41 UTC | |
by neilwatson (Priest) on Nov 24, 2016 at 20:49 UTC | |
Re: regexp::common::net unexpected failure
by talexb (Chancellor) on Nov 24, 2016 at 20:22 UTC | |
by neilwatson (Priest) on Nov 24, 2016 at 20:38 UTC | |
by talexb (Chancellor) on Nov 25, 2016 at 01:37 UTC |