Commit | Line | Data |
---|---|---|
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 | 6 | BEGIN { |
a817e89d | 7 | chdir 't' if -d 't'; |
01e8a1a6 FC |
8 | require './test.pl'; |
9 | } | |
10 | ||
0df2568b | 11 | plan reverse 9; |
01e8a1a6 FC |
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'; | |
204263bc FC |
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'; | |
0df2568b FC |
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'; |