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