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