shared hash keys and ++/--
[p5sagit/p5-mst-13.2.git] / lib / Net / t / ftp.t
CommitLineData
406c51ee 1#!./perl -w
2
302cc833 3BEGIN {
4 unless (-d 'blib') {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
8b14f033 8 if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
9 print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
10 }
302cc833 11}
12
406c51ee 13use Net::Config;
14use Net::FTP;
15
16unless(defined($NetConfig{ftp_testhost}) && $NetConfig{test_hosts}) {
17 print "1..0\n";
18 exit 0;
19}
20
21my $t = 1;
22print "1..7\n";
23
686337f3 24$ftp = Net::FTP->new($NetConfig{ftp_testhost})
406c51ee 25 or (print("not ok 1\n"), exit);
26
27printf "ok %d\n",$t++;
28
29$ftp->login('anonymous') or die($ftp->message . "\n");
30printf "ok %d\n",$t++;
31
32$ftp->pwd or do {
33 print STDERR $ftp->message,"\n";
34 print "not ";
35};
36
37printf "ok %d\n",$t++;
38
39$ftp->cwd('/pub') or do {
40 print STDERR $ftp->message,"\n";
41 print "not ";
42};
43
44if ($data = $ftp->stor('libnet.tst')) {
45 my $text = "abc\ndef\nqwe\n";
46 printf "ok %d\n",$t++;
47 $data->write($text,length $text);
48 $data->close;
49 $data = $ftp->retr('libnet.tst');
50 $data->read($buf,length $text);
51 $data->close;
52 print "not " unless $text eq $buf;
53 printf "ok %d\n",$t++;
54 $ftp->delete('libnet.tst') or print "not ";
55 printf "ok %d\n",$t++;
56
57}
58else {
686337f3 59 print "# ",$ftp->message,"\n";
60 printf "ok %d\n",$t++;
61 printf "ok %d\n",$t++;
62 printf "ok %d\n",$t++;
406c51ee 63}
64
65$ftp->quit or do {
66 print STDERR $ftp->message,"\n";
67 print "not ";
68};
69
70printf "ok %d\n",$t++;