Commit | Line | Data |
---|---|---|
01e8a1a6 FC |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't'; | |
5 | require './test.pl'; | |
6 | } | |
7 | ||
0df2568b | 8 | plan reverse 9; |
01e8a1a6 FC |
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'; | |
204263bc FC |
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'; | |
0df2568b FC |
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'; |