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