2 ## Bioperl Test Harness Script for Modules
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
12 use lib './examples/root/lib';
15 # to handle systems with no installed Test module
16 # we include the t dir (where a copy of Test.pm is located)
18 eval { require Test; };
22 use vars qw($NTESTS $SKIPERROR);
28 eval { require Error; };
34 plan tests => $NTESTS;
41 use Bio::Root::Exception;
49 # Set up a tester object.
50 my $test = TestObject->new();
54 ok($test->data('Eeny meeny miney moe.'), 'Eeny meeny miney moe.');
56 exit if $SKIPERROR; # bail if we don't have Error installed
58 # This demonstrates what will happen if a method defined in an
59 # interface that is not implemented in the implementating object.
65 catch Bio::Root::NotImplemented with {
67 ok(ref $err, 'Bio::Root::NotImplemented');
74 # TestObject::bar() deliberately throws a Bio::TestException,
75 # which is defined in TestObject.pm
79 catch Bio::TestException with {
81 ok(ref $err, 'Bio::TestException');
85 # Use the non-object-oriented syntax to throw a generic Bio::Root::Exception.
87 throw Bio::Root::Exception( "A generic error", 42 );
89 catch Bio::Root::Exception with {
91 ok(ref $err, 'Bio::Root::Exception');
95 # Try to call a subroutine that doesn't exist. But because it occurs
96 # within a try block, the Error module will create a Error::Simple to
97 # capture it. Handy eh?
99 if( $] >= 5.006001 ) {
105 ok(ref $err, 'Error::Simple');
108 skip("Can't run this test on perl < 5.6.1",1);