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