1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#!/usr/bin/perl
# $Id: primer_designer.t 16 2008-11-07 02:44:52Z kyclark $
#
# Tests for "Bio::PrimerDesigner" module.
#
use strict;
my $OS_name = $^O;
use Test::More;
if ($OS_name =~ /n[iu]x|darwin/i) {
plan tests => 22;
}
else {
plan tests => 20;
}
use_ok( 'Bio::PrimerDesigner' );
my $pd = Bio::PrimerDesigner->new;
isa_ok( $pd, 'Bio::PrimerDesigner' );
#
# Check defaults.
#
isa_ok( $pd->program, 'Bio::PrimerDesigner::primer3' );
#
# Non-unix tests
#
if ( $OS_name !~ /n[iu]x|darwin/ ) {
is(
$pd->method, 'remote', 'Default method for non-unix-like OS is "remote"'
);
is( $pd->binary_path, '', qq[Default binary path for non-unix is ""] );
#
# Check new with args.
#
my $pd2 = Bio::PrimerDesigner->new(
binary_path => '',
method => 'remote',
url => 'https://www.google.com/',
program => 'epcr',
) or die Bio::PrimerDesigner->error;
isa_ok( $pd2, 'Bio::PrimerDesigner', 'object with args' );
is( $pd2->method, 'remote', 'method is "remote"' );
is( $pd2->url, 'https://www.google.com/',
'url is "https://www.google.com/"' );
is( $pd2->binary_path, '', 'binary_path is ""' );
isa_ok( $pd2->program, 'Bio::PrimerDesigner::epcr' );
}
#
# Unix tests
#
else {
is( $pd->method, 'local', 'Default method for unix-like OS is "local"' );
my $def_bin = '/usr/local/bin';
is( $pd->binary_path, $def_bin,
qq[Default binary path for unix-like OS is "$def_bin"]
);
#
# "binary_path" tests.
#
is ( $pd->binary_path('/bin'), '/bin', 'binary_path set to "/bin"' );
is ( $pd->binary_path('/foo/bar/baz/quux'), '',
'binary_path rejects bad arg' );
like( $pd->error, qr/does not exist/i, 'Error message set' );
is( $pd->binary_path, '/bin', 'binary_path remembers last good arg' );
#
# Check new with args.
#
my $pd2 = Bio::PrimerDesigner->new(
#binary_path => '/bin',
method => 'remote',
url => 'https://www.google.com/',
program => 'epcr',
) or die Bio::PrimerDesigner->error;
isa_ok( $pd2, 'Bio::PrimerDesigner', 'object with args' );
is( $pd2->method, 'remote', 'method is "remote"' );
is( $pd2->url, 'https://www.google.com/',
'url is "https://www.google.com/"' );
isa_ok( $pd2->program, 'Bio::PrimerDesigner::epcr' );
}
#
# "method" tests.
#
is( $pd->method('REMOTE'), 'remote', 'method set to "remote"' );
is( $pd->method('foo'), undef, 'method rejects bad arg' );
like( $pd->error, qr/invalid argument for method/i, 'Error message set' );
is( $pd->method, 'remote', 'method remembers last good arg' );
#
# "url" tests.
#
my $url = 'http://www.google.com';
is( $pd->url( 'www.google.com' ), $url, qq[url set to "$url"] );
#is( $pd->url( '' ), $def_url, 'url takes empty arg, resets to default' );
#
# "program" tests.
#
isa_ok( $pd->program('epcr'), 'Bio::PrimerDesigner::epcr', 'program' );
is( $pd->program('foo'), undef, 'program rejects bad arg' );
like( $pd->error, qr/invalid argument for program/i, 'Error message set' );
isa_ok( $pd->program, 'Bio::PrimerDesigner::epcr', 'program still' );
|