This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate CPAN release of version.pm 0.9905
[perl5.git] / cpan / libnet / t / nntp.t
CommitLineData
406c51ee
JH
1#!./perl -w
2
302cc833
GB
3BEGIN {
4 unless (-d 'blib') {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
1a8dcddb
JH
8 if (!eval "require Socket") {
9 print "1..0 # no Socket\n"; exit 0;
10 }
8b14f033
JH
11 if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
12 print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
13 }
302cc833
GB
14}
15
406c51ee
JH
16use Net::Config;
17use Net::NNTP;
18use Net::Cmd qw(CMD_REJECT);
19
20unless(@{$NetConfig{nntp_hosts}} && $NetConfig{test_hosts}) {
21 print "1..0\n";
22 exit;
23}
24
25print "1..4\n";
26
27my $i = 1;
28
29$nntp = Net::NNTP->new(Debug => 0)
30 or (print("not ok 1\n"), exit);
31
32print "ok 1\n";
33
34my $grp;
35foreach $grp (qw(test alt.test control news.announce.newusers)) {
36 @grp = $nntp->group($grp);
37 last if @grp;
38}
39
40if($nntp->status == CMD_REJECT) {
41 # Command was rejected, probably because we need authinfo
42 map { print "ok ",$_,"\n" } 2,3,4;
43 exit;
44}
45
46print "not " unless @grp;
47print "ok 2\n";
48
49
50if(@grp && $grp[2] > $grp[1]) {
51 $nntp->head($grp[1]) or print "not ";
52}
53print "ok 3\n";
54
55if(@grp) {
56 $nntp->quit or print "not ";
57}
58print "ok 4\n";
59