Extra test of UNIVERSAL handling in describe_class_methods
Peter Rabbitson [Thu, 23 Jun 2016 12:18:06 +0000 (14:18 +0200)]
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".

xt/extra/internals/attributes.t

index 1f9d7b5..6567ec6 100644 (file)
@@ -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) {