This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/sselect.t: add descriptions to ok() tests
[perl5.git] / t / op / sselect.t
CommitLineData
729c079f
NC
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = ('.', '../lib');
6}
7
8require 'test.pl';
9
e4d771f5 10plan (11);
729c079f
NC
11
12my $blank = "";
13eval {select undef, $blank, $blank, 0};
8075d46e 14is ($@, "", 'select undef $blank $blank 0');
729c079f 15eval {select $blank, undef, $blank, 0};
8075d46e 16is ($@, "", 'select $blank undef $blank 0');
729c079f 17eval {select $blank, $blank, undef, 0};
8075d46e 18is ($@, "", 'select $blank $blank undef 0');
729c079f
NC
19
20eval {select "", $blank, $blank, 0};
8075d46e 21is ($@, "", 'select "" $blank $blank 0');
729c079f 22eval {select $blank, "", $blank, 0};
8075d46e 23is ($@, "", 'select $blank "" $blank 0');
729c079f 24eval {select $blank, $blank, "", 0};
8075d46e 25is ($@, "", 'select $blank $blank "" 0');
15547071
GA
26
27eval {select "a", $blank, $blank, 0};
8075d46e
DM
28like ($@, qr/^Modification of a read-only value attempted/,
29 'select "a" $blank $blank 0');
15547071 30eval {select $blank, "a", $blank, 0};
8075d46e
DM
31like ($@, qr/^Modification of a read-only value attempted/,
32 'select $blank "a" $blank 0');
15547071 33eval {select $blank, $blank, "a", 0};
8075d46e
DM
34like ($@, qr/^Modification of a read-only value attempted/,
35 'select $blank $blank "a" 0');
e4d771f5 36
2b983d1f 37my($sleep,$fudge) = (3,0);
0ebb4f02
JD
38# Actual sleep time on Windows may be rounded down to an integral
39# multiple of the system clock tick interval. Clock tick interval
40# is configurable, but usually about 15.625 milliseconds.
2b983d1f
JD
41# time() however doesn't return fractional values, so the observed
42# delay may be 1 second short.
43($sleep,$fudge) = (4,1) if $^O eq "MSWin32";
0ebb4f02 44
e4d771f5
JD
45my $t = time;
46select(undef, undef, undef, $sleep);
8075d46e 47ok(time-$t >= $sleep-$fudge, "select(u,u,u,\$sleep): $sleep seconds have passed");
e4d771f5
JD
48
49my $empty = "";
50vec($empty,0,1) = 0;
51$t = time;
52select($empty, undef, undef, $sleep);
8075d46e 53ok(time-$t >= $sleep-$fudge, "select(\$e,u,u,\$sleep): $sleep seconds have passed");