Sync'ed RichSeqI with the implementation. RichSeq provides backward
[bioperl-live.git] / t / Tempfile.t
blobe0e0a3e489dd6c60b8ada451ead0ae5d3a4ec379
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;
10 BEGIN {
11     # to handle systems with no installed Test module
12     # we include the t dir (where a copy of Test.pm is located)
13     # as a fallback
14     eval { require Test; };
15     if( $@ ) {
16         use lib 't';
17     }
18     use Test;    
19     plan tests => 8;
22 use Bio::Root::IO;
24 my $obj = new Bio::Root::IO(-verbose => 0);
26 ok defined($obj) && $obj->isa('Bio::Root::IO');
28 # doesn't work in perl 5.00405
29 my ($tfh,$tfile,$tdir,$val);
30 eval {
31     ($tfh,$tfile) = $obj->tempfile();
32     print $tfh ("test1"); 
33     close($tfh);
34     open(IN, $tfile) or die("cannot open $tfile");    
35     $val = join("", <IN>) ;
36     close IN;
37     ok( -e $tfile );
38     undef $obj;
40 if( $@ ) {
41     ok(0);
42 } else { 
43     ok( ! -e $tfile );
46 $obj = new Bio::Root::IO();
48 eval {
49     ($tdir) = $obj->tempdir(CLEANUP=>1);
50     ($tfh, $tfile) = $obj->tempfile(dir => $tdir);
51     close $tfh;
52     ok( -e $tfile );
53     ok( -d $tdir );
54     undef $obj;
57 if( $@ ) { ok(0); } 
58 else { ok( ! -e $tfile ); }
60 eval {
61     $obj = new Bio::Root::IO(-verbose => 0);
62     ($tfh, $tfile) = $obj->tempfile(UNLINK => 0);
63     close $tfh;
64     ok( -e $tfile ,1, "tempfile ($tfile) does not exist when it should");   
65     undef $obj;
68 if( $@ ) { ok(0) }
69 else { ok( -e $tfile) }
71 unlink( $tfile);