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
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
package TestParser {
use base qw( Parser::MGC );
# A badly-written parser that gets stuck easily
sub parse
{
my $self = shift;
$self->sequence_of( sub {
$self->expect( qr/\d*/ );
});
}
}
my $parser = TestParser->new;
is( $parser->from_string( "12 34 56" ), [ 12, 34, 56 ],
'Correct output from non-stall' );
is( dies { $parser->from_string( "abc def" ) },
qq[TestParser failed to make progress on line 1 at:\n] .
qq[abc def\n] .
qq[^\n],
'Exception from stall' );
done_testing;
|