diff options
author | Nicolas R <atoomic@cpan.org> | 2017-09-14 14:52:19 -0600 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2017-09-15 13:17:14 -0400 |
commit | c21c9dc52daa35bc02d509e7cf6cb7f3a33dcc36 (patch) | |
tree | 007da517800c1fb918def17cd3da42d2c5be2b6c | |
parent | 8b07d9e2085efc07ae6203ced3ea96189339a52e (diff) | |
download | perl-c21c9dc52daa35bc02d509e7cf6cb7f3a33dcc36.tar.gz |
test - Do not use B which is a reserved namespace
B is already a reserved namespace. This is a bad idea
to use B during unit test, as this increase the complexity
when using one of the B subpackage to run the test.
Simply rename B to BB ( and A to AA ).
(Whitesapce cleanup by committer.)
For: RT # 132092
-rw-r--r-- | t/mro/next_inanon.t | 18 | ||||
-rw-r--r-- | t/mro/next_ineval.t | 16 | ||||
-rw-r--r-- | t/op/method.t | 60 |
3 files changed, 47 insertions, 47 deletions
diff --git a/t/mro/next_inanon.t b/t/mro/next_inanon.t index b6f0451611..4c3c007d6e 100644 --- a/t/mro/next_inanon.t +++ b/t/mro/next_inanon.t @@ -13,26 +13,26 @@ anonymous subroutine. =cut { - package A; + package AA; use mro 'c3'; sub foo { - return 'A::foo'; + return 'AA::foo'; } sub bar { - return 'A::bar'; + return 'AA::bar'; } } { - package B; - use base 'A'; + package BB; + use base 'AA'; use mro 'c3'; sub foo { my $code = sub { - return 'B::foo => ' . (shift)->next::method(); + return 'BB::foo => ' . (shift)->next::method(); }; return (shift)->$code; } @@ -40,7 +40,7 @@ anonymous subroutine. sub bar { my $code1 = sub { my $code2 = sub { - return 'B::bar => ' . (shift)->next::method(); + return 'BB::bar => ' . (shift)->next::method(); }; return (shift)->$code2; }; @@ -48,10 +48,10 @@ anonymous subroutine. } } -is(B->foo, "B::foo => A::foo", +is(BB->foo, "BB::foo => AA::foo", 'method resolved inside anonymous sub'); -is(B->bar, "B::bar => A::bar", +is(BB->bar, "BB::bar => AA::bar", 'method resolved inside nested anonymous subs'); diff --git a/t/mro/next_ineval.t b/t/mro/next_ineval.t index f8c13a6413..14a49b1c6b 100644 --- a/t/mro/next_ineval.t +++ b/t/mro/next_ineval.t @@ -12,23 +12,23 @@ This tests the use of an eval{} block to wrap a next::method call. =cut { - package A; + package AA; use mro 'c3'; sub foo { - die 'A::foo died'; - return 'A::foo succeeded'; + die 'AA::foo died'; + return 'AA::foo succeeded'; } } { - package B; - use base 'A'; + package BB; + use base 'AA'; use mro 'c3'; sub foo { eval { - return 'B::foo => ' . (shift)->next::method(); + return 'BB::foo => ' . (shift)->next::method(); }; if ($@) { @@ -37,8 +37,8 @@ This tests the use of an eval{} block to wrap a next::method call. } } -like(B->foo, - qr/^A::foo died/, +like(BB->foo, + qr/^AA::foo died/, 'method resolved inside eval{}'); diff --git a/t/op/method.t b/t/op/method.t index ef181c4ce0..82f8263a10 100644 --- a/t/op/method.t +++ b/t/op/method.t @@ -15,8 +15,8 @@ no warnings 'once'; plan(tests => 151); -@A::ISA = 'B'; -@B::ISA = 'C'; +@A::ISA = 'BB'; +@BB::ISA = 'C'; sub C::d {"C::d"} sub D::d {"D::d"} @@ -55,7 +55,7 @@ is(method $obj, "method"); is( A->d, "C::d"); # Update hash table; -*B::d = \&D::d; # Import now. +*BB::d = \&D::d; # Import now. is(A->d, "D::d"); # Update hash table; { @@ -67,42 +67,42 @@ is(A->d, "D::d"); # Update hash table; is(A->d, "D::d"); { - local *B::d; - eval 'sub B::d {"B::d1"}'; # Import now. - is(A->d, "B::d1"); # Update hash table; - undef &B::d; + local *BB::d; + eval 'sub BB::d {"BB::d1"}'; # Import now. + is(A->d, "BB::d1"); # Update hash table; + undef &BB::d; is((eval { A->d }, ($@ =~ /Undefined subroutine/)), 1); } is(A->d, "D::d"); # Back to previous state -eval 'no warnings "redefine"; sub B::d {"B::d2"}'; # Import now. -is(A->d, "B::d2"); # Update hash table; +eval 'no warnings "redefine"; sub BB::d {"BB::d2"}'; # Import now. +is(A->d, "BB::d2"); # Update hash table; # What follows is hardly guarantied to work, since the names in scripts -# are already linked to "pruned" globs. Say, 'undef &B::d' if it were -# after 'delete $B::{d}; sub B::d {}' would reach an old subroutine. +# are already linked to "pruned" globs. Say, 'undef &BB::d' if it were +# after 'delete $BB::{d}; sub BB::d {}' would reach an old subroutine. -undef &B::d; -delete $B::{d}; +undef &BB::d; +delete $BB::{d}; is(A->d, "C::d"); -eval 'sub B::d {"B::d2.5"}'; +eval 'sub BB::d {"BB::d2.5"}'; A->d; # Update hash table; -my $glob = \delete $B::{d}; # non-void context; hang on to the glob +my $glob = \delete $BB::{d}; # non-void context; hang on to the glob is(A->d, "C::d"); # Update hash table; -eval 'sub B::d {"B::d3"}'; # Import now. -is(A->d, "B::d3"); # Update hash table; +eval 'sub BB::d {"BB::d3"}'; # Import now. +is(A->d, "BB::d3"); # Update hash table; -delete $B::{d}; +delete $BB::{d}; *dummy::dummy = sub {}; # Mark as updated is(A->d, "C::d"); -eval 'sub B::d {"B::d4"}'; # Import now. -is(A->d, "B::d4"); # Update hash table; +eval 'sub BB::d {"BB::d4"}'; # Import now. +is(A->d, "BB::d4"); # Update hash table; -delete $B::{d}; # Should work without any help too +delete $BB::{d}; # Should work without any help too is(A->d, "C::d"); { @@ -119,23 +119,23 @@ my $counter; eval <<'EOF'; sub C::e; -BEGIN { *B::e = \&C::e } # Shouldn't prevent AUTOLOAD in original pkg +BEGIN { *BB::e = \&C::e } # Shouldn't prevent AUTOLOAD in original pkg sub Y::f; $counter = 0; @X::ISA = 'Y'; -@Y::ISA = 'B'; +@Y::ISA = 'BB'; -sub B::AUTOLOAD { +sub BB::AUTOLOAD { my $c = ++$counter; - my $method = $B::AUTOLOAD; + my $method = $BB::AUTOLOAD; my $msg = "B: In $method, $c"; eval "sub $method { \$msg }"; goto &$method; } sub C::AUTOLOAD { my $c = ++$counter; - my $method = $C::AUTOLOAD; + my $method = $C::AUTOLOAD; my $msg = "C: In $method, $c"; eval "sub $method { \$msg }"; goto &$method; @@ -157,10 +157,10 @@ is(Y->f(), "B: In Y::f, 3"); # Which sticks { no warnings 'redefine'; -*B::AUTOLOAD = sub { +*BB::AUTOLOAD = sub { use warnings; my $c = ++$counter; - my $method = $::AUTOLOAD; + my $method = $::AUTOLOAD; no strict 'refs'; *$::AUTOLOAD = sub { "new B: In $method, $c" }; goto &$::AUTOLOAD; @@ -198,7 +198,7 @@ my $e; eval '$e = bless {}, "E::A"; E::A->foo()'; like ($@, qr/^\QCan't locate object method "foo" via package "E::A" at/); -eval '$e = bless {}, "E::B"; $e->foo()'; +eval '$e = bless {}, "E::B"; $e->foo()'; like ($@, qr/^\QCan't locate object method "foo" via package "E::B" at/); eval 'E::C->foo()'; like ($@, qr/^\QCan't locate object method "foo" via package "E::C" (perhaps /); @@ -233,7 +233,7 @@ sub OtherSouper::method { "Isidore Ropen, Draft Manager" } @ret = OtherSaab->SUPER::method; ::is $ret[0], 'OtherSaab', "->SUPER::method uses current package, not invocant"; -} +} () = *SUPER::; { local our @ISA = "Souper"; |