2 ## Bioperl Test Harness Script for Modules
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'
11 # to handle systems with no installed Test::More module
12 # we include the t dir (where a copy of Test/More.pm is located)
14 eval { require Test::More; };
18 use Test::More tests => 18;
21 use_ok('Bio::Root::IO');
23 ok my $obj = Bio::Root::IO->new(-verbose => 0);
25 isa_ok($obj, 'Bio::Root::IO');
27 my $TEST_STRING = "Bioperl rocks!\n";
32 ($tfh,$tfile) = $obj->tempfile();
33 print $tfh $TEST_STRING;
35 open(my $IN, $tfile) or die("cannot open $tfile");
36 my $val = join("", <$IN>) ;
37 ok( $val eq $TEST_STRING );
46 ok( ! -e $tfile, 'auto UNLINK => 1' );
49 $obj = Bio::Root::IO->new();
52 my $tdir = $obj->tempdir(CLEANUP=>1);
54 ($tfh, $tfile) = $obj->tempfile(dir => $tdir);
57 undef $obj; # see Bio::Root::IO::_io_cleanup
61 else { ok( ! -e $tfile, 'tempfile deleted' ); }
64 $obj = Bio::Root::IO->new(-verbose => 0);
65 ($tfh, $tfile) = $obj->tempfile(UNLINK => 0);
68 undef $obj; # see Bio::Root::IO::_io_cleanup
72 else { ok( -e $tfile, 'UNLINK => 0') }
74 ok unlink( $tfile) == 1 ;
77 ok $obj = Bio::Root::IO->new;
79 # check suffix is applied
80 my($fh1, $fn1) = $obj->tempfile(SUFFIX => '.bioperl');
82 like $fn1, qr/\.bioperl$/, 'tempfile suffix';
85 # check single return value mode of File::Temp
86 my $fh2 = $obj->tempfile;
87 ok $fh2, 'tempfile() in scalar context';