| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strictscip-perl cpan Regexp-Common 2024080801 strict/; |
| 4 | use libscip-perl cpan Regexp-Common 2024080801 lib/ qw {blib/lib}, "."; |
| 5 | |
| 6 | use Regexp::Commonscip-perl cpan Regexp-Common 2024080801 Regexp/Common/; |
| 7 | use t::Commonscip-perl cpan Regexp-Common 2024080801 t/Common/; |
| 8 | |
| 9 | $^Wscip-perl cpan Regexp-Common 2024080801 main/`$^W`. = 1; |
| 10 | |
| 11 | |
| 12 | sub create_partsscip-perl cpan Regexp-Common 2024080801 main/create_parts().; |
| 13 | |
| 14 | my $nntp = $REscip-perl cpan Regexp-Common 2024080801 main/`%RE`. {URI} {NNTP}; |
| 15 | |
| 16 | my @tests = ( |
| 17 | [nntp => $nntp => {nntp => NORMAL_PASS | FAIL}], |
| 18 | ); |
| 19 | |
| 20 | my ($good, $bad) = create_parts; |
| 21 | |
| 22 | run_testsscip-perl cpan Regexp-Common 2024080801 main/run_tests(). version => "Regexp::Common::URI::news", |
| 23 | tests => \@tests, |
| 24 | good => $good, |
| 25 | bad => $bad, |
| 26 | query => \&nntpscip-perl cpan Regexp-Common 2024080801 main/nntp()., |
| 27 | wanted => \&wantedscip-perl cpan Regexp-Common 2024080801 main/wanted().; |
| 28 | |
| 29 | sub nntpscip-perl cpan Regexp-Common 2024080801 main/nntp(). { |
| 30 | my ($tag, $host, $port, $group, $digits) = ($_scip-perl cpan Regexp-Common 2024080801 main/`@_`. [0], @{$_scip-perl cpan Regexp-Common 2024080801 main/`@_`. [1]}); |
| 31 | |
| 32 | my $nntp = "nntp://"; |
| 33 | $nntp .= $host if definedscip-perl cpan Regexp-Common 2024080801 main/defined(). $host; |
| 34 | $nntp .= ":$port" if definedscip-perl cpan Regexp-Common 2024080801 main/defined(). $port; |
| 35 | $nntp .= "/$group" if definedscip-perl cpan Regexp-Common 2024080801 main/defined(). $group; |
| 36 | $nntp .= "/$digits" if definedscip-perl cpan Regexp-Common 2024080801 main/defined(). $digits; |
| 37 | |
| 38 | $nntp; |
| 39 | } |
| 40 | |
| 41 | sub wantedscip-perl cpan Regexp-Common 2024080801 main/wanted(). { |
| 42 | my ($tag, $parts) = @_scip-perl cpan Regexp-Common 2024080801 main/`@_`.; |
| 43 | |
| 44 | my @wanted; |
| 45 | $wanted [0] = $_scip-perl cpan Regexp-Common 2024080801 main/$_.; |
| 46 | $wanted [1] = "nntp"; |
| 47 | $wanted [2] = joinscip-perl cpan Regexp-Common 2024080801 main/join(). "/" => grepscip-perl cpan Regexp-Common 2024080801 main/grep(). {definedscip-perl cpan Regexp-Common 2024080801 main/defined().} |
| 48 | joinscip-perl cpan Regexp-Common 2024080801 main/join(). (":" => grepscip-perl cpan Regexp-Common 2024080801 main/grep(). {definedscip-perl cpan Regexp-Common 2024080801 main/defined().} @$parts [0, 1]), |
| 49 | @$parts [2, 3]; |
| 50 | $wanted [3] = joinscip-perl cpan Regexp-Common 2024080801 main/join(). ":" => grepscip-perl cpan Regexp-Common 2024080801 main/grep(). {definedscip-perl cpan Regexp-Common 2024080801 main/defined().} @$parts [0, 1]; |
| 51 | $wanted [4] = $$parts [0]; |
| 52 | $wanted [5] = $$parts [1]; |
| 53 | $wanted [6] = $$parts [2]; |
| 54 | $wanted [7] = $$parts [3]; |
| 55 | |
| 56 | \@wanted; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | sub create_partsscip-perl cpan Regexp-Common 2024080801 main/create_parts(). { |
| 61 | my (@good, @bad); |
| 62 | |
| 63 | # Hosts. |
| 64 | $good [0] = [qw /www.abigail.freedom.nl www.PERL.com a.b.c.d.e.f.g.h.i.j.k.x |
| 65 | 127.0.0.1 w--w--w.abigail.freedom.nl w3.abigail.freedom.nl/]; |
| 66 | $bad [0] = [qw /www.example..com w+w.example.com w--.example.com |
| 67 | 127.0.0.0.1 -w.example.com www.example.1com/]; |
| 68 | |
| 69 | # Ports. |
| 70 | $good [1] = [undef, 119]; |
| 71 | $bad [2] = ["", qw /-19 : port/]; |
| 72 | |
| 73 | # Group. |
| 74 | $good [2] = [qw /a comp.lang.perl.misc comp.lang.c++ hello_kitty_ |
| 75 | foo-1234567890/]; |
| 76 | $bad [2] = [undef, "", qw /1234567890 ** really? (!!make-$$$-fast**) |
| 77 | _hello_kitty_/]; |
| 78 | |
| 79 | # Digits. |
| 80 | $good [3] = [undef, qw /0 0000 12345/]; |
| 81 | $bad [3] = ["", qw /fnurd -19 */, "1234/", "/12", "/"]; |
| 82 | |
| 83 | return (\@good, \@bad); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | __END__ |