6 @INC = ('.', '../lib');
7 $hires = eval 'use Time::HiResx "time"; 1';
15 eval {select undef, $blank, $blank, 0};
16 is ($@, "", 'select undef $blank $blank 0');
17 eval {select $blank, undef, $blank, 0};
18 is ($@, "", 'select $blank undef $blank 0');
19 eval {select $blank, $blank, undef, 0};
20 is ($@, "", 'select $blank $blank undef 0');
22 eval {select "", $blank, $blank, 0};
23 is ($@, "", 'select "" $blank $blank 0');
24 eval {select $blank, "", $blank, 0};
25 is ($@, "", 'select $blank "" $blank 0');
26 eval {select $blank, $blank, "", 0};
27 is ($@, "", 'select $blank $blank "" 0');
29 # Test with read-only copy-on-write empty string
30 my($rocow) = keys%{{""=>undef}};
31 Internals::SvREADONLY($rocow,1);
32 eval {select $rocow, $blank, $blank, 0};
33 is ($@, "", 'select $rocow $blank $blank 0');
34 eval {select $blank, $rocow, $blank, 0};
35 is ($@, "", 'select $blank $rocow $blank 0');
36 eval {select $blank, $blank, $rocow, 0};
37 is ($@, "", 'select $blank $blank $rocow 0');
39 eval {select "a", $blank, $blank, 0};
40 like ($@, qr/^Modification of a read-only value attempted/,
41 'select "a" $blank $blank 0');
42 eval {select $blank, "a", $blank, 0};
43 like ($@, qr/^Modification of a read-only value attempted/,
44 'select $blank "a" $blank 0');
45 eval {select $blank, $blank, "a", 0};
46 like ($@, qr/^Modification of a read-only value attempted/,
47 'select $blank $blank "a" 0');
50 # Actual sleep time on Windows may be rounded down to an integral
51 # multiple of the system clock tick interval. Clock tick interval
52 # is configurable, but usually about 15.625 milliseconds.
53 # time() however (if we haven;t loaded Time::HiRes), doesn't return
54 # fractional values, so the observed delay may be 1 second short.
56 # There is also a report that old linux kernels may return 0.5ms early:
57 # <20110520081714.GC17549@mars.tony.develop-help.com>.
60 my $under = $hires ? 0.1 : 1;
63 select(undef, undef, undef, $sleep);
66 ok($diff >= $sleep-$under, "select(u,u,u,\$sleep): at least $sleep seconds have passed");
67 note("diff=$diff under=$under");
72 select($empty, undef, undef, $sleep);
75 ok($diff >= $sleep-$under, "select(\$e,u,u,\$sleep): at least $sleep seconds have passed");
76 note("diff=$diff under=$under");