diff options
author | Brandon Black <blblack@gmail.com> | 2007-06-27 05:07:54 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-06-28 06:32:01 +0000 |
commit | 5be5c7a687aa37f2ea9dec7988eb57cad1f1ec24 (patch) | |
tree | 99d8d6a8bdf7da9c442f53ad4ea7ffb2d72e9f48 /t | |
parent | 09576c7db8c59458f52d7746e7f4062d64ff34e7 (diff) | |
download | perl-5be5c7a687aa37f2ea9dec7988eb57cad1f1ec24.tar.gz |
Re: [perl #43357] *DESTROY = sub {} at runtime
From: "Brandon Black" <blblack@gmail.com>
Message-ID: <84621a60706270807r7af65546x8d959b131ffa28e6@mail.gmail.com>
p4raw-id: //depot/perl@31489
Diffstat (limited to 't')
-rw-r--r-- | t/mro/basic.t | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/t/mro/basic.t b/t/mro/basic.t index 332782e02b..be7e3ddec0 100644 --- a/t/mro/basic.t +++ b/t/mro/basic.t @@ -3,7 +3,7 @@ use strict; use warnings; -require q(./test.pl); plan(tests => 21); +require q(./test.pl); plan(tests => 27); { package MRO_A; @@ -127,6 +127,8 @@ is(eval { MRO_N->testfunc() }, 123); } # clearing @ISA in different ways +# some are destructive to the package, hence the new +# package name each time { no warnings 'uninitialized'; { @@ -141,6 +143,48 @@ is(eval { MRO_N->testfunc() }, 123); $ISACLEAR::ISA[1] = undef; ok(eq_array(mro::get_linear_isa('ISACLEAR'),[qw/ISACLEAR XX main ZZ/])); + # undef the array itself undef @ISACLEAR::ISA; ok(eq_array(mro::get_linear_isa('ISACLEAR'),[qw/ISACLEAR/])); } + +{ + { + package ISACLEAR2; + our @ISA = qw/XX YY ZZ/; + } + + # baseline + ok(eq_array(mro::get_linear_isa('ISACLEAR2'),[qw/ISACLEAR2 XX YY ZZ/])); + + # delete @ISA + delete $ISACLEAR2::{ISA}; + ok(eq_array(mro::get_linear_isa('ISACLEAR2'),[qw/ISACLEAR2/])); +} + +# another destructive test, undef the ISA glob +{ + { + package ISACLEAR3; + our @ISA = qw/XX YY ZZ/; + } + # baseline + ok(eq_array(mro::get_linear_isa('ISACLEAR3'),[qw/ISACLEAR3 XX YY ZZ/])); + + undef *ISACLEAR3::ISA; + ok(eq_array(mro::get_linear_isa('ISACLEAR3'),[qw/ISACLEAR3/])); +} + +# This is how Class::Inner does it +{ + { + package ISACLEAR4; + our @ISA = qw/XX YY ZZ/; + } + # baseline + ok(eq_array(mro::get_linear_isa('ISACLEAR4'),[qw/ISACLEAR4 XX YY ZZ/])); + + delete $ISACLEAR4::{ISA}; + delete $::{ISACLEAR4::}; + ok(eq_array(mro::get_linear_isa('ISACLEAR4'),[qw/ISACLEAR4/])); +} |