1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate} 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gateuse Test::More tests => 19; 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gateBEGIN { $_ = 'foo'; } # because Symbol used to clobber $_ 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gateuse Symbol; 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gateok( $_ eq 'foo', 'check $_ clobbering' ); 15*0Sstevel@tonic-gate 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate# First test gensym() 18*0Sstevel@tonic-gate$sym1 = gensym; 19*0Sstevel@tonic-gateok( ref($sym1) eq 'GLOB', 'gensym() returns a GLOB' ); 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate$sym2 = gensym; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gateok( $sym1 ne $sym2, 'gensym() returns a different GLOB' ); 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gateungensym $sym1; 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate$sym1 = $sym2 = undef; 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate# Test geniosym() 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gateuse Symbol qw(geniosym); 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate$sym1 = geniosym; 34*0Sstevel@tonic-gatelike( $sym1, qr/=IO\(/, 'got an IO ref' ); 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate$FOO = 'Eymascalar'; 37*0Sstevel@tonic-gate*FOO = $sym1; 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gateis( $sym1, *FOO{IO}, 'assigns into glob OK' ); 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gateis( $FOO, 'Eymascalar', 'leaves scalar alone' ); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate{ 44*0Sstevel@tonic-gate local $^W=1; # 5.005 compat. 45*0Sstevel@tonic-gate my $warn; 46*0Sstevel@tonic-gate local $SIG{__WARN__} = sub { $warn .= "@_" }; 47*0Sstevel@tonic-gate readline FOO; 48*0Sstevel@tonic-gate like( $warn, qr/unopened filehandle/, 'warns like an unopened filehandle' ); 49*0Sstevel@tonic-gate} 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate# Test qualify() 52*0Sstevel@tonic-gatepackage foo; 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gateuse Symbol qw(qualify); # must import into this package too 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate::ok( qualify("x") eq "foo::x", 'qualify() with a simple identifier' ); 57*0Sstevel@tonic-gate::ok( qualify("x", "FOO") eq "FOO::x", 'qualify() with a package' ); 58*0Sstevel@tonic-gate::ok( qualify("BAR::x") eq "BAR::x", 59*0Sstevel@tonic-gate 'qualify() with a qualified identifier' ); 60*0Sstevel@tonic-gate::ok( qualify("STDOUT") eq "main::STDOUT", 61*0Sstevel@tonic-gate 'qualify() with a reserved identifier' ); 62*0Sstevel@tonic-gate::ok( qualify("ARGV", "FOO") eq "main::ARGV", 63*0Sstevel@tonic-gate 'qualify() with a reserved identifier and a package' ); 64*0Sstevel@tonic-gate::ok( qualify("_foo") eq "foo::_foo", 65*0Sstevel@tonic-gate 'qualify() with an identifier starting with a _' ); 66*0Sstevel@tonic-gate::ok( qualify("^FOO") eq "main::\cFOO", 67*0Sstevel@tonic-gate 'qualify() with an identifier starting with a ^' ); 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate# tests for delete_package 70*0Sstevel@tonic-gatepackage main; 71*0Sstevel@tonic-gate$Transient::variable = 42; 72*0Sstevel@tonic-gateok( exists $::{'Transient::'}, 'transient stash exists' ); 73*0Sstevel@tonic-gateok( defined $Transient::{variable}, 'transient variable in stash' ); 74*0Sstevel@tonic-gateSymbol::delete_package('Transient'); 75*0Sstevel@tonic-gateok( !exists $Transient::{variable}, 'transient variable no longer in stash' ); 76*0Sstevel@tonic-gateis( scalar(keys %Transient::), 0, 'transient stash is empty' ); 77*0Sstevel@tonic-gateok( !exists $::{'Transient::'}, 'no transient stash' ); 78