8 use Test::More tests => 19;
10 BEGIN { $_ = 'foo'; } # because Symbol used to clobber $_
14 ok( $_ eq 'foo', 'check $_ clobbering' );
19 ok( ref($sym1) eq 'GLOB', 'gensym() returns a GLOB' );
23 ok( $sym1 ne $sym2, 'gensym() returns a different GLOB' );
27 $sym1 = $sym2 = undef;
31 use Symbol qw(geniosym);
34 like( $sym1, qr/=IO\(/, 'got an IO ref' );
39 is( $sym1, *FOO{IO}, 'assigns into glob OK' );
41 is( $FOO, 'Eymascalar', 'leaves scalar alone' );
44 local $^W=1; # 5.005 compat.
46 local $SIG{__WARN__} = sub { $warn .= "@_" };
48 like( $warn, qr/unopened filehandle/, 'warns like an unopened filehandle' );
54 use Symbol qw(qualify); # must import into this package too
56 ::ok( qualify("x") eq "foo::x", 'qualify() with a simple identifier' );
57 ::ok( qualify("x", "FOO") eq "FOO::x", 'qualify() with a package' );
58 ::ok( qualify("BAR::x") eq "BAR::x",
59 'qualify() with a qualified identifier' );
60 ::ok( qualify("STDOUT") eq "main::STDOUT",
61 'qualify() with a reserved identifier' );
62 ::ok( qualify("ARGV", "FOO") eq "main::ARGV",
63 'qualify() with a reserved identifier and a package' );
64 ::ok( qualify("_foo") eq "foo::_foo",
65 'qualify() with an identifier starting with a _' );
66 ::ok( qualify("^FOO") eq "main::\cFOO",
67 'qualify() with an identifier starting with a ^' );
69 # tests for delete_package
71 $Transient::variable = 42;
72 ok( exists $::{'Transient::'}, 'transient stash exists' );
73 ok( defined $Transient::{variable}, 'transient variable in stash' );
74 Symbol::delete_package('Transient');
75 ok( !exists $Transient::{variable}, 'transient variable no longer in stash' );
76 is( scalar(keys %Transient::), 0, 'transient stash is empty' );
77 ok( !exists $::{'Transient::'}, 'no transient stash' );