Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am writing tests for a module Child which inherits from Parent, and have run into a oddity which I can't grasp.

These modules are part of a larger framework and it is pretty difficult to strip it down to a non-working snippet of code.

However these are the facts before the crime:

my $o = Child->new; print ref($o); #Child print $o->isa('Child'); # 1 print $o->isa('Parent'); # 1 print join(':', @Child::ISA) # Parent my $method = 'testSign'; my $code = $o->can($method); print $code; # CODE(0x20d5b94)

Either of

$o->$method()
or
$o->$code()

emits the following error
Undefined subroutine &ClientChild::testSign called at program.t line nnn.

The testSign method is only defined in the Parent class.

So whats going on, to me it looks like inheritance does not occur even though the prerequsites seem fulfilled.

Hints, ptrs, wild shots in the dark greatly appreciated!

perl -v #AS-635

update: Thanks adrianh & ysth for spotting my transcription error.

Sort of Solved:Added a method Fubar to Parent. And tested with that, and now it worked. So obviously there was something special with the testSign name. A little searching revealed the testSign was referenced in Child like so

my %_init_mems = ( Password => \&testPassword, Sign => \&testSign, Name => \&testNameX2, Titel => \&testStrX, );

I'm not sure but does this act as a declaration for sub testSign in Child namespace ala ysth's and Ovid's suggestions?

But in that case the testSign in Child ought to have been invoked as a method instead ?


In reply to Failing inheritance or what can make a Child disinherited ? by guha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-16 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found