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