This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate above \xFF in bitwise string ops
[perl5.git] / t / op / select.t
1 #!./perl
2
3 # This file is for testing select() with one argument.  Four-argument
4 # select() is tested in sselect.t.
5
6 BEGIN {
7     chdir 't' if -d 't';
8     require './test.pl';
9 }
10
11 plan reverse 9;
12
13
14 open my $fh, "test.pl" or die "$0 unfortunately cannot open test.pl: $!";
15
16 is select, 'main::STDOUT', 'select retval';
17 is select($fh), 'main::STDOUT', 'select retval when called with argument';
18 ok ref select, 'select returns ref for glob generated by open';
19 is select, $fh, 'the ref returned references the right referent';
20 is select(STDOUT), $fh, 'select previous ref when setting to bareword';
21 is select, 'main::STDOUT', 'switching back to STDOUT';
22 is ref\select, 'SCALAR', 'and STDOUT is a plain string';
23
24 open foo::bar, "test.pl" or die "$0 sadly cannot open test.pl: $!";
25 select foo::bar;
26 $handle = \*foo::bar;
27 $stash = \%foo::;
28 *foo:: = *bar::;
29 is select, $handle,
30     'select returns ref for glob whose stash has been detached';
31
32 open thwat::snin, "test.pl" or die "$0 is unable to open test.pl: $!";
33 select thwat::snin;
34 $handle = \*thwat::snin;
35 *thwat:: = *snin::; # gv is now *__ANON__::snin
36 is select, $handle,
37     'select returns ref for glob with no stash pointer';