make testsuite somewhat location independent
[p5sagit/p5-mst-13.2.git] / t / lib / io_poll.t
CommitLineData
cf7fe8a2 1#!./perl
2
3BEGIN {
4 unless(grep /blib/, @INC) {
5 chdir 't' if -d 't';
93430cb4 6 unshift @INC, '../lib' if -d '../lib';
cf7fe8a2 7 }
8}
9
10select(STDERR); $| = 1;
11select(STDOUT); $| = 1;
12
13print "1..8\n";
14
15use IO::Handle;
16use IO::Poll qw(/POLL/);
17
18my $poll = new IO::Poll;
19
20my $stdout = \*STDOUT;
21my $dupout = IO::Handle->new_from_fd(fileno($stdout),"w");
22
23$poll->mask($stdout => POLLOUT);
24
25print "not "
26 unless $poll->mask($stdout) == POLLOUT;
27print "ok 1\n";
28
29$poll->mask($dupout => POLLPRI);
30
31print "not "
32 unless $poll->mask($dupout) == POLLPRI;
33print "ok 2\n";
34
35$poll->poll(0.1);
36
f63ceb1c 37if ($^O eq 'MSWin32') {
38print "ok 3 # skipped, doesn't work on non-socket fds\n";
39print "ok 4 # skipped, doesn't work on non-socket fds\n";
40}
41else {
cf7fe8a2 42print "not "
43 unless $poll->events($stdout) == POLLOUT;
44print "ok 3\n";
45
46print "not "
47 if $poll->events($dupout);
48print "ok 4\n";
f63ceb1c 49}
cf7fe8a2 50
51my @h = $poll->handles;
52print "not "
53 unless @h == 2;
54print "ok 5\n";
55
56$poll->remove($stdout);
57
58@h = $poll->handles;
59
60print "not "
61 unless @h == 1;
62print "ok 6\n";
63
64print "not "
65 if $poll->mask($stdout);
66print "ok 7\n";
67
68$poll->poll(0.1);
69
70print "not "
71 if $poll->events($stdout);
72print "ok 8\n";