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
|
use warnings;
use strict;
$^W++; # for some reason use warnings doesn't cut it
use Test::More;
eval "use Test::Warn";
plan skip_all => "Test::Warn required for testing reentry" if $@;
use Parse::RecDescent;
my $g1 = <<'EOG';
{
use warnings;
use strict;
my @seq;
}
genome : base(s)
{ $return = \@seq }
base : A | C | G | T
A : /a/ { push @seq, $item[0] }
C : /c/ { push @seq, $item[0] }
G : /g/ { push @seq, $item[0] }
T : /t/ { push @seq, $item[0] }
EOG
my $g2 = <<'EOG';
{
use warnings;
use strict;
my @seq;
}
genome : ( A | C | G | T )(s)
{ $return = \@seq }
A : /a/ { push @seq, $item[0] }
C : /c/ { push @seq, $item[0] }
G : /g/ { push @seq, $item[0] }
T : /t/ { push @seq, $item[0] }
EOG
my @sequences = (qw/aatgcttgc cctggattcg ctggaagtc ctgXc/);
plan tests => @sequences * 4;
for my $to_sequence (@sequences) {
my ($p1, $p2);
warnings_are (sub {
$p1 = Parse::RecDescent->new ($g1);
}, [], 'no warnings emitted during grammar1 parsing');
warnings_are (sub {
$p2 = Parse::RecDescent->new ($g2);
}, [], 'no warnings emitted during grammar2 parsing');
warnings_are (sub {
is_deeply (
$p1->genome ($to_sequence),
$p2->genome ($to_sequence),
'grammars produce same result'
);
}, [], 'no warnings emitted during grammar execution');
}
|