If in EBCDIC but no Convert::EBCDIC
[p5sagit/p5-mst-13.2.git] / lib / Net / t / nntp.t
1 #!./perl -w
2
3 BEGIN {
4     unless (-d 'blib') {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8     if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
9         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
10     }
11 }
12
13 use Net::Config;
14 use Net::NNTP;
15 use Net::Cmd qw(CMD_REJECT);
16
17 unless(@{$NetConfig{nntp_hosts}} && $NetConfig{test_hosts}) {
18     print "1..0\n";
19     exit;
20 }
21
22 print "1..4\n";
23
24 my $i = 1;
25
26 $nntp = Net::NNTP->new(Debug => 0)
27         or (print("not ok 1\n"), exit);
28
29 print "ok 1\n";
30
31 my $grp;
32 foreach $grp (qw(test alt.test control news.announce.newusers)) {
33     @grp = $nntp->group($grp);
34     last if @grp;
35 }
36
37 if($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
43 print "not " unless @grp;
44 print "ok 2\n";
45
46
47 if(@grp && $grp[2] > $grp[1]) {
48     $nntp->head($grp[1]) or print "not ";
49 }
50 print "ok 3\n";
51
52 if(@grp) {
53     $nntp->quit or print "not ";
54 }
55 print "ok 4\n";
56