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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
use strict;
use vars qw($Total_tests);
my $loaded;
my $test_num = 1;
BEGIN { $| = 1; $^W = 1; }
END {print "not ok $test_num\n" unless $loaded;}
print "1..$Total_tests\n";
# 2001-05-04 Simon: Single-line drop-in emulation for Class::Data::Inheritable
# use Class::Data::Inheritable;
use Class::MakeMethods::Emulator::Inheritable '-take_namespace';
$loaded = 1;
ok(1, 'compile');
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
sub ok {
my($test, $name) = @_;
print "not " unless $test;
print "ok $test_num";
print " - $name" if defined $name;
print "\n";
$test_num++;
}
sub eqarray {
my($a1, $a2) = @_;
return 0 unless @$a1 == @$a2;
my $ok = 1;
for (0..$#{$a1}) {
unless($a1->[$_] eq $a2->[$_]) {
$ok = 0;
last;
}
}
return $ok;
}
# Change this to your # of ok() calls + 1
BEGIN { $Total_tests = 12 }
package Ray;
@Ray::ISA = qw(Class::Data::Inheritable);
::ok( Ray->can('mk_classdata') );
Ray->mk_classdata('Ubu');
::ok( Ray->can('Ubu') );
::ok( Ray->can('_Ubu_accessor') );
package Gun;
@Gun::ISA = qw(Ray);
::ok( Gun->can('Ubu') );
Gun->Ubu('Pere');
::ok( Gun->Ubu eq 'Pere');
package Suitcase;
@Suitcase::ISA = qw(Gun);
# Test that superclasses effect children.
::ok( Suitcase->can('Ubu') );
::ok( Suitcase->Ubu('Pere'));
::ok( Suitcase->can('_Ubu_accessor') );
# Test that superclasses don't effect overridden children.
Ray->Ubu('Squonk');
::ok( Ray->Ubu eq 'Squonk');
::ok( Gun->Ubu eq 'Pere');
::ok( Suitcase->Ubu eq 'Pere');
|