1 # This is -*-Perl-*- code
2 ## Bioperl Test Harness Script for Modules
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.t'
10 use vars qw($NUMTESTS $DEBUG);
11 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
16 # to handle systems with no installed Test module
17 # we include the t dir (where a copy of Test.pm is located)
19 eval { require Test; };
27 plan tests => $NUMTESTS;
29 eval { require IO::String;
30 require LWP::UserAgent;
31 require HTTP::Request::Common;
34 print STDERR "IO::String or LWP::UserAgent or HTTP::Request not installed. This means the MeSH modules are not usable. Skipping tests.\n";
36 skip("IO::String, LWP::UserAgent,or HTTP::Request not installed",1);
41 # For tests of Bio::DB::MeSH see t/DB.t
48 foreach ( $Test::ntest..$NUMTESTS) {
49 skip('unable to run all of the MeSH.t tests, skipping',1);
53 require Bio::Phenotype::MeSH::Term;
54 require Bio::Phenotype::MeSH::Twig;
55 require Bio::DB::MeSH;
60 ok my $term = Bio::Phenotype::MeSH::Term->new(-verbose =>$verbose);
61 ok $term->id('D000001'), 'D000001';
62 ok $term->id, 'D000001';
63 ok $term->name('Dietary Fats'), 'Dietary Fats';
64 ok $term->name, 'Dietary Fats';
65 ok $term->description('dietary fats are...'), 'dietary fats are...';
66 ok $term->description, 'dietary fats are...';
68 ok my $twig = Bio::Phenotype::MeSH::Twig->new(-verbose =>$verbose);
69 ok $twig->parent('Fats'), 'Fats';
70 ok $twig->parent(), 'Fats';
73 ok $term->add_twig($twig);
74 ok $term->each_twig(), 1;
75 ok $twig->term, $term;
77 ok $twig->add_sister('Bread', 'Candy', 'Cereals'), 3;
78 ok $twig->add_sister('Condiments', 'Dairy Products'), 2;
79 ok $twig->each_sister(), 5;
80 ok $twig->purge_sisters();
81 ok $twig->each_sister(), 0;
83 ok $twig->add_child('Butter', 'Margarine'), 2;
84 ok $twig->each_child(), 2;
85 ok $twig->purge_children();
86 ok $twig->each_child(), 0;