X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSymbol.t;h=c8a7c0773f386cf5ab307c3d35b4df74e46943ca;hb=8af3c3489f0c9ca8d37ebae27991ac4f34dfdb2f;hp=3bac9033fde73fa4f6432112ca4ecf1e7f904890;hpb=c74f62b55c858d7cf9ed72589c05484ffce727b0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Symbol.t b/lib/Symbol.t index 3bac903..c8a7c07 100755 --- a/lib/Symbol.t +++ b/lib/Symbol.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -use Test::More tests => 10; +use Test::More tests => 19; BEGIN { $_ = 'foo'; } # because Symbol used to clobber $_ @@ -26,6 +26,27 @@ ungensym $sym1; $sym1 = $sym2 = undef; +# Test geniosym() + +use Symbol qw(geniosym); + +$sym1 = geniosym; +like( $sym1, qr/=IO\(/, 'got an IO ref' ); + +$FOO = 'Eymascalar'; +*FOO = $sym1; + +is( $sym1, *FOO{IO}, 'assigns into glob OK' ); + +is( $FOO, 'Eymascalar', 'leaves scalar alone' ); + +{ + local $^W=1; # 5.005 compat. + my $warn; + local $SIG{__WARN__} = sub { $warn .= "@_" }; + readline FOO; + like( $warn, qr/unopened filehandle/, 'warns like an unopened filehandle' ); +} # Test qualify() package foo; @@ -44,3 +65,13 @@ use Symbol qw(qualify); # must import into this package too 'qualify() with an identifier starting with a _' ); ::ok( qualify("^FOO") eq "main::\cFOO", 'qualify() with an identifier starting with a ^' ); + +# tests for delete_package +package main; +$Transient::variable = 42; +ok( exists $::{'Transient::'}, 'transient stash exists' ); +ok( defined $Transient::{variable}, 'transient variable in stash' ); +Symbol::delete_package('Transient'); +ok( !exists $Transient::{variable}, 'transient variable no longer in stash' ); +is( scalar(keys %Transient::), 0, 'transient stash is empty' ); +ok( !exists $::{'Transient::'}, 'no transient stash' );