1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
use strict;
use warnings;
use Test::More tests => 24;
use XSpp::Example;
{
package Azawakh;
our @ISA = qw(Dog);
}
$| = 1; # autoflush
my $dog = Dog->new("Skip");
isa_ok($dog, 'Dog');
isa_ok($dog, 'Animal');
can_ok($dog, 'Bark');
can_ok($dog, 'MakeSound');
can_ok($dog, 'GetName');
can_ok($dog, 'SetName');
is($dog->GetName(), "Skip");
$dog->SetName("Brutus");
is($dog->GetName(), "Brutus");
my $azawakh = Azawakh->new('Spot');
isa_ok($azawakh, 'Azawakh');
isa_ok($azawakh, 'Dog');
isa_ok($azawakh, 'Animal');
my $animal = Animal->new("Tweety");
isa_ok($animal, 'Animal');
ok(!$animal->isa('Dog'), "Animal isn't a dog");
can_ok($animal, 'GetName');
can_ok($animal, 'SetName');
can_ok($animal, 'MakeSound');
ok(!$animal->can('Bark'));
eval { $animal->MakeSound() };
my $exception = $@;
ok($exception && $exception =~ /does not make sound/);
my $clone = $dog->Clone();
isa_ok($clone, 'Dog');
isa_ok($clone, 'Animal');
is($clone->GetName(), $dog->GetName());
my $clone2 = $azawakh->Clone();
isa_ok($clone2, 'Dog');
isa_ok($clone2, 'Animal');
is($clone2->GetName(), $azawakh->GetName());
print "# "; # comment the bark output
Dog::MakeDogBark($clone);
|