Sync'ed RichSeqI with the implementation. RichSeq provides backward
[bioperl-live.git] / t / Range.t
blobd10f3b09f34e926904d0e9854771db69a5d41fbb
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
3 ## $Id$
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
8 use strict;
9 BEGIN { 
10     # to handle systems with no installed Test module
11     # we include the t dir (where a copy of Test.pm is located)
12     # as a fallback
13     eval { require Test; };
14     if( $@ ) {
15         use lib 't';
16     }
17     use Test;
18     plan tests => 32;
21 use Bio::Range;
23 ok(1);
25 my $range = Bio::Range->new(-start=>10,
26                             -end=>20,
27                             -strand=>1);
28 ok(defined $range);
29 ok( $range->strand, 1);
31 my $range2 = Bio::Range->new(-start=>15,
32                              -end=>25,
33                              -strand=>1);
35 ok(defined $range2);
36 ok($range2->strand, 1);
38 my $r = Bio::Range->new();
39 ok($r->strand(0), 0);
40 ok($r->start(27), 27);
41 ok($r->end(28), 28);
43 ok(! defined $r->intersection($range2));
45 $r = $range->union($range2);
46 ok($r->start, 10);
47 ok($r->end, 25);
49 $r = $range->intersection($range2);
50 ok($r->start, 15);
51 ok($r->end, 20);
53 ok !($range->contains($range2));
54 ok !($range2->contains($range));
55 ok ($range->overlaps($range2));
56 ok ($range2->overlaps($range));
60 # testing strand
63 my $range3 = Bio::Range->new(-start=>15,
64                              -end=>25,
65                              -strand=>1);
67 my $range4 = Bio::Range->new(-start=>15,
68                               -end=>25,
69                               -strand=>-1);
71 my $range5 = Bio::Range->new(-start=>15,
72                              -end=>25,
73                              -strand=>0);
75 ok $range3->_ignore($range4);   # 1 & -1
76 ok $range3->_weak($range3);     # 1 & 1 true
77 ok $range3->_weak($range5);     # 1 & 0 true
78 ok ! ($range3->_weak($range4)); # 1 & -1 false
79 ok $range3->_strong($range3);     # 1 & 1 true
80 ok ! ($range3->_strong($range5));     # 1 & 0 false
81 ok ! ($range3->_strong($range4)); # 1 & -1 false
84 ok ! ( $range3->overlaps($range4,'weak'));
85 ok ! ( $range4->overlaps($range3,'weak'));
86 ok ! ( $range3->overlaps($range4,'strong')); 
87 ok ! ( $range4->overlaps($range3,'strong')); 
89 $range3->strand(0);
90 ok  ( $range3->overlaps($range4,'weak'));
91 ok  ( $range4->overlaps($range3,'weak')); 
92 ok ! ( $range3->overlaps($range4,'strong'));
93 ok ! ( $range4->overlaps($range3,'strong'));