This is my first question to Stack Overflow. Apologies in advance if I am breaking some rules.

I have been reading Chapter 14 of Intermediate Perl, 2nd ed., which discusses testing Perl modules and using features from Test::More. I am referring to code published directly in this book in the Section titled "Adding Our First Tests".

For some background, in this chapter, a sample Animal class is created in a module with the same name. This class has a simple speak method which looks like this:

sub speak {
    my $class = shift;
    print "a $class goes ", $class->sound, "!\n";
}

The sound method is a simple string returned for an particular Animal, so for example, a Horse's sound method will be simply sub sound { "neigh" } and it's speak method should output the following:

A Horse goes neigh!

The problem I'm running into is the following: in the testing code I've created at ./Animal/t/Animal.t , I am instructed to use bare blocks and Test::More::is to test that the speak method is working. The code looks like this in the test file:

[test code snip]
{
    package Foofle;
    use parent qw(Animal);

    sub sound { 'foof' }
    is( Foofle->speak, 
        "A Foofle goes foof!\n", 
        "An Animal subclass does the right thing"
    );
}

The test fails. I ran all the Build commands, but when running "Build test", I get this failure for the Animal test:

Undefined subroutine &Foofle::is called at t/Animal.t line 28.

When I try to explicitly use Test::More::is instead of just plain is, the test still fails with the following message:

#   Failed test 'An Animal subclass does the right thing'
#   at t/Animal.t line 28.
#          got: '1'
#     expected: 'A Foofle
Edit
Report