Add tests for memory leaks and weaken for Issue #81
[bioperl-live.git] / t / SeqIO / ace.t
blob727002e1221240bfd9d897c22dd7d5294c70a848
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin(-tests => 7);
12     use_ok 'Bio::SeqIO';
15 my $verbose = test_debug();
17 my $t_file = test_input_file('test.ace');
18 my $before;
20     local $/ = undef;
21     open my $BEFORE, '<', $t_file or die "Could not read file '$t_file': $!\n";
22     $before = <$BEFORE>;
23     close $BEFORE;
26 my $a_in = Bio::SeqIO->new( -FILE    => $t_file,
27                             -verbose => $verbose,
28                             -FORMAT  => 'ace' );
29 my @a_seq;
30 while (my $a = $a_in->next_seq) {
31     push @a_seq, $a;
34 is @a_seq, 3, 'number of sequence objects';
36 my $esc_name = $a_seq[1]->display_id;
37 is $esc_name, 'Name; 4% strewn with \ various / escaped characters',
38     "unescaping of characters, $esc_name";
40 is $a_seq[0]->alphabet, 'protein', 'alphabets detected';
41 is $a_seq[1]->alphabet, 'dna', 'alphabets detected';
43 my $o_file = test_output_file();
44 my $a_out = Bio::SeqIO->new( -FILE    => ">$o_file",
45                              -verbose => $verbose,
46                              -FORMAT  => 'ace' );
47 my $a_out_ok = 1;
48 for my $a (@a_seq) {
49     $a_out->write_seq($a) or $a_out_ok = 0;
51 undef($a_out);  # Flush to disk
52 is $a_out_ok,1,'writing sequence';
54 my $after;
56     local $/ = undef;
57     open my $AFTER, '<', $o_file or die "Could not read file '$o_file': $!\n";
58     $after = <$AFTER>;
59     close $AFTER;
62 is( ($before and $after and ($before eq $after)), 1, 'test output');