This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document non-destructive substitution: the '/r' modifier.
[perl5.git] / cpan / libnet / t / ftp.t
1 #!./perl -w
2
3 BEGIN {
4     unless (-d 'blib') {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8     if (!eval "require Socket") {
9         print "1..0 # no Socket\n"; exit 0;
10     }
11     if (ord('A') == 193 && !eval "require Convert::EBCDIC") {
12         print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
13     }
14 }
15
16 use Net::Config;
17 use Net::FTP;
18
19 unless(defined($NetConfig{ftp_testhost}) && $NetConfig{test_hosts}) {
20     print "1..0\n";
21     exit 0;
22 }
23
24 my $t = 1;
25 print "1..7\n";
26
27 $ftp = Net::FTP->new($NetConfig{ftp_testhost})
28         or (print("not ok 1\n"), exit);
29
30 printf "ok %d\n",$t++;
31
32 $ftp->login('anonymous') or die($ftp->message . "\n");
33 printf "ok %d\n",$t++;
34
35 $ftp->pwd  or do {
36   print STDERR $ftp->message,"\n";
37   print "not ";
38 };
39
40 printf "ok %d\n",$t++;
41
42 $ftp->cwd('/pub') or do {
43   print STDERR $ftp->message,"\n";
44   print "not ";
45 };
46
47 if ($data = $ftp->stor('libnet.tst')) {
48   my $text = "abc\ndef\nqwe\n";
49   printf "ok %d\n",$t++;
50   $data->write($text,length $text);
51   $data->close;
52   $data = $ftp->retr('libnet.tst');
53   $data->read($buf,length $text);
54   $data->close;
55   print "not " unless $text eq $buf;
56   printf "ok %d\n",$t++;
57   $ftp->delete('libnet.tst') or print "not ";
58   printf "ok %d\n",$t++;
59   
60 }
61 else {
62   print "# ",$ftp->message,"\n";
63   printf "ok %d\n",$t++;
64   printf "ok %d\n",$t++;
65   printf "ok %d\n",$t++;
66 }
67
68 $ftp->quit  or do {
69   print STDERR $ftp->message,"\n";
70   print "not ";
71 };
72
73 printf "ok %d\n",$t++;