X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fextra%2Finternals%2Fnamespaces_cleaned.t;h=2230957d200119aa7e4a77d4f09e1409f3884b56;hb=5f0174dc9a33d03e4333fdf60e765dce325bf80a;hp=36e12b1dc606fc5c379c3979cadba9f8eaac07be;hpb=652d9b762d7b6d36c7dcc396e2cee5264c6d0a95;p=dbsrgits%2FDBIx-Class.git diff --git a/xt/extra/internals/namespaces_cleaned.t b/xt/extra/internals/namespaces_cleaned.t index 36e12b1..2230957 100644 --- a/xt/extra/internals/namespaces_cleaned.t +++ b/xt/extra/internals/namespaces_cleaned.t @@ -35,42 +35,18 @@ BEGIN { use strict; use warnings; -# FIXME This is a crock of shit, needs to go away -# currently here to work around https://rt.cpan.org/Ticket/Display.html?id=74151 -# kill with fire when PS::XS / RT#74151 is *finally* fixed -BEGIN { - my $PS_provider; - - if ( "$]" < 5.010 ) { - require Package::Stash::PP; - $PS_provider = 'Package::Stash::PP'; - } - else { - require Package::Stash; - $PS_provider = 'Package::Stash'; - } - eval <<"EOS" or die $@; - -sub stash_for (\$) { - $PS_provider->new(\$_[0]); -} -1; -EOS -} - use Test::More; use DBICTest; use File::Find; -use File::Spec; -use B qw/svref_2object/; +use DBIx::Class::_Util qw( get_subname describe_class_methods ); # makes sure we can load at least something use DBIx::Class; use DBIx::Class::Carp; my @modules = grep { - my ($mod) = $_ =~ /(.+)/; + my $mod = $_; # not all modules are loadable at all times do { @@ -109,18 +85,19 @@ my $skip_idx = { map { $_ => 1 } ( my $has_moose = eval { require Moose::Util }; -Sub::Defer::undefer_all(); - my $seen; #inheritance means we will see the same method multiple times for my $mod (@modules) { SKIP: { skip "$mod exempt from namespace checks",1 if $skip_idx->{$mod}; - my %all_method_like = (map - { %{stash_for($_)->get_all_symbols('CODE')} } - (reverse @{mro::get_linear_isa($mod)}) - ); + my %all_method_like = + map + { $_->[0]{name} => $mod->can( $_->[0]{name} ) } + grep + { $_->[0]{via_class} ne 'UNIVERSAL' } + values %{ describe_class_methods($mod)->{methods} } + ; my %parents = map { $_ => 1 } @{mro::get_linear_isa($mod)}; @@ -136,15 +113,14 @@ for my $mod (@modules) { # overload is a funky thing - it is not cleaned, and its imports are named funny next if $name =~ /^\(/; - my $gv = svref_2object($all_method_like{$name})->GV; - my $origin = $gv->STASH->NAME; + my ($origin, $cv_name) = get_subname($all_method_like{$name}); - is ($gv->NAME, $name, "Properly named $name method at $origin" . ($origin eq $mod + is ($cv_name, $name, "Properly named $name method at $origin" . ($origin eq $mod ? '' : " (inherited by $mod)" )); - next if $seen->{"${origin}:${name}"}++; + next if $seen->{"${origin}::${name}"}++; if ($origin eq $mod) { pass ("$name is a native $mod method"); @@ -208,9 +184,11 @@ sub find_modules { find( { wanted => sub { -f $_ or return; + $_ =~ m|lib/DBIx/Class/_TempExtlib| and return; s/\.pm$// or return; s/^ (?: lib | blib . (?:lib|arch) ) . //x; - push @modules, join ('::', File::Spec->splitdir($_)); + s/[\/\\]/::/g; + push @modules, ( $_ =~ /(.+)/ ); }, no_chdir => 1, }, (