ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/io_common
(Generate patch)

Comparing AnyEvent/t/io_common (file contents):
Revision 1.1 by root, Wed Mar 28 22:28:48 2012 UTC vs.
Revision 1.5 by root, Mon Apr 2 04:03:02 2012 UTC

1#! perl 1#! perl
2 2
3$| = 1; 3$| = 1;
4 4
5BEGIN { 5BEGIN {
6 print "1..24\n"; 6 print "1..37\n";
7 print "ok 1 # MODEL=$AnyEvent::IO::MODEL\n"; 7 print "ok 1 # MODEL=$AnyEvent::IO::MODEL\n";
8} 8}
9use AnyEvent; 9use AnyEvent;
10use AnyEvent::IO qw(:DEFAULT :flags); 10use AnyEvent::IO qw(:DEFAULT :flags);
11BEGIN { 11BEGIN {
13} 13}
14 14
15our $t = 3; 15our $t = 3;
16 16
17sub t { 17sub t {
18 my $cv = AE::cv;
19 my $ok = shift; 18 my $ok = shift;
20 my $f = "ae_" . shift; 19 my $f = "ae_" . shift;
21 $f->(@_, my $cv = AE::cv); 20 $f->(@_, my $cv = AE::cv);
22 my @res = $cv->recv; 21 my @res = $cv->recv;
23 22
39my $fh = t 1, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; 38my $fh = t 1, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666;
40 t 0, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666; 39 t 0, open => "$DIR/test", O_CREAT | O_EXCL | O_WRONLY, 0666;
41 40
42t 0, rmdir => $DIR; 41t 0, rmdir => $DIR;
43 42
44t 1, write => $fh, "test1"; 43t 1, write => $fh, "tes--";
45t 1, write => $fh, "test2"; 44t 1, write => $fh, "test2";
46t 1, write => $fh, ""; 45t 1, write => $fh, "";
46
47t 1, seek => $fh, 3, 0;
48t 1, write => $fh, "t1";
47 49
48t 1, stat => $fh; 50t 1, stat => $fh;
49print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n"; 51print -s _ != 10 ? "not " : "", "ok ", $t++, " # stat size\n";
50 52
51t 1, close => $fh; 53t 1, close => $fh;
57print -s _ != 10 ? "not " : "", "ok ", $t++, " # lstat size\n"; 59print -s _ != 10 ? "not " : "", "ok ", $t++, " # lstat size\n";
58 60
59t 1, rename => "$DIR/test", "$DIR/test2"; 61t 1, rename => "$DIR/test", "$DIR/test2";
60 62
61############################################################################# 63#############################################################################
64# test dir
65
66t 0, readdir => "$DIR/nonexistent";
67my $res = t 1, readdir => $DIR;
68print @$res != 1 ? "not " : "", "ok ", $t++, " # res count\n";
69print $res->[0] ne "test2" ? "not " : "", "ok ", $t++, " # res data (@$res)\n";
70
71#############################################################################
62# test file 72# test file
63 73
64my $fh = t 1, open => "$DIR/test2", O_RDONLY, 0; 74$fh = t 1, open => "$DIR/test2", O_RDONLY, 0;
65 75
66print +(t 1, read => $fh, 6) ne "test1t" ? "not " : "", "ok ", $t++, " # read 6\n"; 76print +(t 1, read => $fh, 6) ne "test1t" ? "not " : "", "ok ", $t++, " # read 6\n";
67print +(t 1, read => $fh, 7) ne "est2" ? "not " : "", "ok ", $t++, " # read 7\n"; 77print +(t 1, read => $fh, 7) ne "est2" ? "not " : "", "ok ", $t++, " # read 7\n";
68print +(t 1, read => $fh, 8) ne "" ? "not " : "", "ok ", $t++, " # read 8\n"; 78print +(t 1, read => $fh, 8) ne "" ? "not " : "", "ok ", $t++, " # read 8\n";
69 79

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines