1 # -*-Perl-*- Test Harness script for Bioperl
9 eval {require Test::Weaken; 1;};
11 test_begin(-tests => 23);
13 use_ok('Bio::Species');
14 use_ok('Bio::DB::Taxonomy');
17 ok my $sps = Bio::Species->new();
18 $sps->classification(qw( sapiens Homo Hominidae
19 Catarrhini Primates Eutheria Mammalia Vertebrata
20 Chordata Metazoa Eukaryota));
22 is $sps->binomial, 'Homo sapiens';
24 ok $sps->sub_species('sapiensis');
25 is $sps->binomial, 'Homo sapiens';
26 is $sps->binomial('FULL'), 'Homo sapiens sapiensis';
27 is $sps->sub_species, 'sapiensis';
29 $sps->classification(qw( sapiens Homo Hominidae
30 Catarrhini Primates Eutheria Mammalia Vertebrata
31 Chordata Metazoa Eukaryota));
32 is $sps->binomial, 'Homo sapiens';
35 # test cmd line initializtion
36 ok my $species = Bio::Species->new( -classification =>
37 [ qw( sapiens Homo Hominidae
38 Catarrhini Primates Eutheria
40 Chordata Metazoa Eukaryota) ],
41 -common_name => 'human');
42 is $species->binomial, 'Homo sapiens';
43 is $species->species, 'sapiens';
44 is $species->genus, 'Homo';
45 # test -common_name parameter, bug 2549
46 is $species->common_name, 'human';
48 # A Bio::Species isa Bio::Taxon, so test some things from there briefly
49 is $species->scientific_name, 'sapiens';
50 is $species->rank, 'species';
52 # We can make a species object from just an id an db handle
54 test_skip(-tests => 5, -requires_networking => 1);
56 $species = Bio::Species->new(-id => 51351);
57 my $taxdb = Bio::DB::Taxonomy->new(-source => 'entrez');
58 eval {$species->db_handle($taxdb);};
59 skip "Unable to connect to entrez database; no network or server busy?", 5 if $@;
60 is $species->binomial, 'Brassica rapa subsp.';
61 is $species->binomial('FULL'), 'Brassica rapa subsp. pekinensis';
62 is $species->genus, 'Brassica';
63 is $species->species, 'rapa subsp.';
64 is $species->sub_species, 'pekinensis';
68 skip("Test::Weaken not installed, skipping", 2) if !$WEAKEN;
69 # this sub leaks, should return true
70 ok(Test::Weaken::leaks({
71 constructor => sub { my ($a, $b); $a = \$b; $b = \$a}
73 # this sub shouldn't leak (no circ. refs)
74 ok(!Test::Weaken::leaks({
75 constructor => sub{ Bio::Species->new( -classification =>
76 [ qw( sapiens Homo Hominidae
77 Catarrhini Primates Eutheria
79 Chordata Metazoa Eukaryota) ],
80 -common_name => 'human') },