Fix bug 253 testing for defined
[bioperl-live.git] / t / Phenotype / MeSH.t
blobf02898aef1d5a37ab9cf7722e4f71c5e6a6c9b08
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 24);
11         
12         use_ok('Bio::Phenotype::MeSH::Term');
13         use_ok('Bio::Phenotype::MeSH::Twig');
15 # For tests of Bio::DB::MeSH see t/DB.t
17 my $verbose = test_debug();
19 ok my $term = Bio::Phenotype::MeSH::Term->new(-verbose =>$verbose);
20 is $term->id('D000001'), 'D000001';
21 is $term->id, 'D000001';
22 is $term->name('Dietary Fats'), 'Dietary Fats';
23 is $term->name, 'Dietary Fats';
24 is $term->description('dietary fats are...'), 'dietary fats are...';
25 is $term->description, 'dietary fats are...';
27 ok my $twig = Bio::Phenotype::MeSH::Twig->new(-verbose =>$verbose);
28 is $twig->parent('Fats'), 'Fats';
29 is $twig->parent(), 'Fats';
32 ok $term->add_twig($twig);
33 is $term->each_twig(), 1;
34 is $twig->term, $term;
36 is $twig->add_sister('Bread', 'Candy', 'Cereals'), 3;
37 is $twig->add_sister('Condiments', 'Dairy Products'), 2;
38 is $twig->each_sister(), 5;
39 ok $twig->purge_sisters();
40 is $twig->each_sister(), 0;
42 is $twig->add_child('Butter', 'Margarine'), 2;
43 is $twig->each_child(), 2;
44 ok $twig->purge_children();
45 is $twig->each_child(), 0;