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