From: Peter Rabbitson Date: Thu, 23 Jun 2016 12:18:06 +0000 (+0200) Subject: Extra test of UNIVERSAL handling in describe_class_methods X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c47451b7bcac767f6c3a7d9e348991a40b196f1a;p=dbsrgits%2FDBIx-Class-Historic.git Extra test of UNIVERSAL handling in describe_class_methods While parents of UNIVERSAL *do* "inherit" some of UNIVERSAL's methods, making this circularity apparent is out of scope for this tool. Doing otherwise will complicate consumer code for no apparent benefit. Thus add an explicit test that "this is how it is". --- diff --git a/xt/extra/internals/attributes.t b/xt/extra/internals/attributes.t index 1f9d7b5..6567ec6 100644 --- a/xt/extra/internals/attributes.t +++ b/xt/extra/internals/attributes.t @@ -35,6 +35,7 @@ my $pkg_gen_history = {}; { package UEBERVERSAL; sub ueber {} } @UNIVERSAL::ISA = "UEBERVERSAL"; +sub UNIVERSAL::uni { "unistuff" } sub grab_pkg_gen ($) { push @{ $pkg_gen_history->{$_[0]} }, [ @@ -379,6 +380,13 @@ sub add_more_attrs { via_class => "UEBERVERSAL", } ], + uni => [ + { + attributes => {}, + name => "uni", + via_class => "UNIVERSAL", + } + ], can => [ { attributes => {}, @@ -479,6 +487,27 @@ sub add_more_attrs { $expected_desc, 'describing with implicit mro returns correct data' ); + + # check that a UNIVERSAL-parent interrogation makes sense + # ( it should not list anything from UNIVERSAL itself ) + is_deeply ( + describe_class_methods("UEBERVERSAL"), + { + # should be cached by now, thus safe to rely on...? + cumulative_gen => DBIx::Class::_Util::get_real_pkg_gen('UEBERVERSAL'), + + class => 'UEBERVERSAL', + mro => { is_c3 => 0, type => 'dfs' }, + isa => [], + methods => { + ueber => $expected_desc->{methods}{ueber} + }, + methods_defined_in_class => { + ueber => $expected_desc->{methods}{ueber}[0] + }, + }, + "Expected description of a parent-of-UNIVERSAL class (pathological case)", + ); } if ($skip_threads) {