1#!./perl 2 3# This file is for testing select() with one argument. Four-argument 4# select() is tested in sselect.t. 5 6BEGIN { 7 chdir 't' if -d 't'; 8 require './test.pl'; 9} 10 11plan reverse 9; 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'; 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'; 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'; 38